可能重复:
How can I start apache derby programmatically jar file?
我创建了一个包含客户信息的桌面应用程序。该计划
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!!");
}
}
或者如果我在C:\ Program Files \ Java \ jdk1.7.0_03 \ db \ bin中启动startNetworkServer.bat
这很好用。
但是如何自动启动该bat文件?