import java.awt.*;
import java.awt.event.*;
import java.sql.SQLException;
import javax.swing.*;
public class Mainframe extends JFrame {
private static String[] data = {};
private static JComboBox cb_commands = new JComboBox(data);
private static JTextField tx_sql = new JTextField();
private static JTextArea ta_output = new JTextArea("");
private JButton b_execute = new JButton();
private JLabel jLabel1 = new JLabel();
private JLabel jLabel2 = new JLabel();
private Font f = new Font("ComicSans", Font.BOLD, 12);
private Database db = Database.getInstance();
private JButton b_close = new JButton();
public Mainframe(String title) {
super(title);
initialize();
try {
db.connect();
} catch (SQLException ex) {
ta_output.setText(ex.toString());
} catch (ClassNotFoundException ex) {
ta_output.setText(ex.toString());
}
}
private void initialize() {
Container cp = getContentPane();
cp.setLayout(null);
cb_commands.setFont(f);
cb_commands.setBounds(24, 110, 210, 24);
cb_commands.setBackground(Color.WHITE);
cb_commands.setForeground(Color.BLACK);
cb_commands.addItem("..........");
cb_commands.addItem(" 0-9 ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" A ... ");
cb_commands.addItem("Action");
cb_commands.addItem("Action2Systemrole");
cb_commands.addItem("AuthenticationInstrument");
cb_commands.addItem("AuthenticationMethod");
cb_commands.addItem("AuthenticationMethod2Channel");
cb_commands.addItem("Author2Document");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" B ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" C ...");
cb_commands.addItem("Category");
cb_commands.addItem("Category Keyword");
cb_commands.addItem("Change Request");
cb_commands.addItem("Channel");
cb_commands.addItem("Commentaries");
cb_commands.addItem("Community");
cb_commands.addItem("CommunityTemplates");
cb_commands.addItem("CommunityUser");
cb_commands.addItem("CommunityUsergroup");
cb_commands.addItem("ComminutyWorkflow");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" D ...");
cb_commands.addItem("Document");
cb_commands.addItem("DocumentArchive");
cb_commands.addItem("DocumentField");
cb_commands.addItem("DocumentFieldArchive");
cb_commands.addItem("DocumentHistory");
cb_commands.addItem("DocumentParticipants");
cb_commands.addItem("DocumentRating");
cb_commands.addItem("DocumentSignature");
cb_commands.addItem("DocumentTypeCategory");
cb_commands.addItem("DocumentTypeSequence");
cb_commands.addItem("Document2Category");
cb_commands.addItem("Document2Document");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" E ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" F ...");
cb_commands.addItem("Favorites");
cb_commands.addItem("FQSFDocument");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" G ...");
cb_commands.addItem("Group2WFRole");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" H ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" I ...");
cb_commands.addItem("IntendedReleasePeriodDate");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" J ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" K ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" L ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" M ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" N ...");
cb_commands.addItem("News");
cb_commands.addItem("Notification");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" O ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" P ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" Q ...");
cb_commands.addItem("QSFDocument");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" R ...");
cb_commands.addItem("RatingItem");
cb_commands.addItem("RatingType");
cb_commands.addItem("ReviewReleaseDate");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" S ...");
cb_commands.addItem("Systemrole");
cb_commands.addItem("Systemuser");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" T ...");
cb_commands.addItem("Template");
cb_commands.addItem("TemplateCategory");
cb_commands.addItem("TemplateField");
cb_commands.addItem("TemplateWorkflow");
cb_commands.addItem("TimeForInitialTraining");
cb_commands.addItem("TrainingParicipant");
cb_commands.addItem("TrainingSession");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" U ...");
cb_commands.addItem("Usergroup");
cb_commands.addItem("User2Systemrole");
cb_commands.addItem("User2Usergroup");
cb_commands.addItem("User2WFRole");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" V ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" W ...");
cb_commands.addItem("WFRole");
cb_commands.addItem("WFRole2WFStatus");
cb_commands.addItem("WFRole2WFTrans");
cb_commands.addItem("WFStatus");
cb_commands.addItem("WFStatusphases");
cb_commands.addItem("WFStatus Properties");
cb_commands.addItem("WFTransition");
cb_commands.addItem("WFTransitionConditions");
cb_commands.addItem("WFTransitionConstraints");
cb_commands.addItem("WFTransitionFinalizers");
cb_commands.addItem("WFTransitionProperties");
cb_commands.addItem("WFWorkflow");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" X ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" Y ...");
cb_commands.addItem("--------------------------------------------");
cb_commands.addItem(" Z ...");
cb_commands.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
tx_sql.setText(cb_commands.getSelectedItem().toString());
}
});
cp.add(cb_commands);
tx_sql.setBounds(288, 48, 393, 80);
cp.add(tx_sql);
b_execute.setBounds(310, 152, 175, 41);
b_execute.setText("SQL-Befehl ausführen");
b_execute.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
db.executeDBCommand(tx_sql.getText());
} catch (SQLException ex) {
ta_output.setText(ex.toString());
}
}
});
cp.add(b_execute);
jLabel1.setBounds(24, 95, 150, 16);
jLabel1.setText("Tabelle auswählen");
jLabel1.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel1);
jLabel2.setBounds(296, 24, 131, 16);
jLabel2.setText("SQL-Befehl eingeben:");
jLabel2.setFont(new Font("MS Sans Serif", Font.PLAIN, 13));
cp.add(jLabel2);
ta_output.setText("");
ta_output.setBounds(64, 220, 593, 225);
ta_output.setEditable(false);
cp.add(ta_output);
b_close.setBounds(64, 152, 175, 41);
b_close.setText("Verbindung trennen");
b_close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
db.close();
ta_output.setText("Verbindung beendet");
} catch (SQLException ex) {
ta_output.setText(ex.toString());
}
}
});
cp.add(b_close);
}
public static void main(String[] args) {
Mainframe frame = new Mainframe("Oracle-Test-Datenbank-Zugriff");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(730, 575);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}