我创建了一个包含一些客户信息的桌面应用程序。该程序
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection conn= DriverManager.getConnection("jdbc:derby://localhost:1527/data;create=true;user=APP;password=app");
String id = jTextField1.getText();
String name = jTextField2.getText();
String query = "INSERT INTO CUSTOMER(id, Name) VALUES (' "+id+" ',' "+name+"')";
Statement stmt = conn.createStatement();
int executeUpdate = stmt.executeUpdate(query);
int ans =JOptionPane.showConfirmDialog(null, "Record Saved Successfully. Do you want to Add More Data ?");
if (ans== JOptionPane.YES_OPTION){
this.dispose();
window1 newWindow = new window1();
newWindow.setVisible(true);
}
}
catch ( ClassNotFoundException | SQLException e) {
JOptionPane.showMessageDialog(null, "Cannot Save!!");
}
}
或者,如果我从startNetworkServer.bat
C:\Program Files\Java\jdk1.7.0_03\db\bin 开始,这可以正常工作。
但是如何自动启动那个bat文件呢?