import java.sql.Connection;
public class Kundenstamm {
protected Shell shell;
private static Text df_CustomerNumber;
private Text df_FirstName;
private Text df_SecondName;
private Text df_Company;
private Text df_City;
private Text df_TelephoneNumber;
private Text df_Email;
private Text df_Street;
/**
* Launch the application.
* @param args
*/
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@myhost:1521:orcl";
Connection con = DriverManager.getConnection(url, "System", "test");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select dummy from dual");
while (rs.next()) {
//System.out.println(rs.getString(1));
df_CustomerNumber.setText("Result: " + rs.getString(1));
}
try {
Kundenstamm window = new Kundenstamm();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
/**
* Create contents of the window.
*/
protected void createContents() {
shell = new Shell();
shell.setSize(476, 438);
shell.setText("Kundenstamm");
df_CustomerNumber = new Text(shell, SWT.BORDER);
df_CustomerNumber.setBounds(10, 31, 200, 21);
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setBounds(10, 10, 200, 15);
lblNewLabel.setText("Customer number");
Label lblFirstName = new Label(shell, SWT.NONE);
lblFirstName.setText("First name");
lblFirstName.setBounds(10, 62, 200, 15);
df_FirstName = new Text(shell, SWT.BORDER);
df_FirstName.setBounds(10, 83, 200, 21);
Label lblSecondName = new Label(shell, SWT.NONE);
lblSecondName.setText("Second Name");
lblSecondName.setBounds(10, 110, 200, 15);
df_SecondName = new Text(shell, SWT.BORDER);
df_SecondName.setBounds(10, 131, 200, 21);
Label lblCompany = new Label(shell, SWT.NONE);
lblCompany.setText("Company");
lblCompany.setBounds(10, 158, 200, 15);
df_Company = new Text(shell, SWT.BORDER);
df_Company.setBounds(10, 179, 200, 21);
Label lblStreet = new Label(shell, SWT.NONE);
lblStreet.setText("Street");
lblStreet.setBounds(10, 206, 200, 15);
Label lblCity = new Label(shell, SWT.NONE);
lblCity.setText("City");
lblCity.setBounds(10, 254, 200, 15);
df_City = new Text(shell, SWT.BORDER);
df_City.setBounds(10, 275, 200, 21);
df_TelephoneNumber = new Text(shell, SWT.BORDER);
df_TelephoneNumber.setBounds(10, 323, 200, 21);
Label lblEmail = new Label(shell, SWT.NONE);
lblEmail.setText("Email");
lblEmail.setBounds(10, 350, 200, 15);
df_Email = new Text(shell, SWT.BORDER);
df_Email.setBounds(10, 371, 200, 21);
df_Street = new Text(shell, SWT.BORDER);
df_Street.setBounds(10, 227, 200, 21);
Label lblTelephoneNumber = new Label(shell, SWT.NONE);
lblTelephoneNumber.setText("Telephone number");
lblTelephoneNumber.setBounds(10, 302, 200, 15);
Button pb_Search = new Button(shell, SWT.NONE);
pb_Search.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Ladevorgang
}
});
pb_Search.setBounds(216, 29, 75, 25);
pb_Search.setText("search");
Button pb_New = new Button(shell, SWT.NONE);
pb_New.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Neuanlage eines Datensatzes
}
});
pb_New.setText("new");
pb_New.setBounds(297, 29, 75, 25);
Button pb_Delete = new Button(shell, SWT.NONE);
pb_Delete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// Löschung eines Datensatzes
}
});
pb_Delete.setText("delete");
pb_Delete.setBounds(378, 29, 75, 25);
}
}