1

可能重复:
如何以编程方式启动 apache derby jar 文件?

我创建了一个包含一些客户信息的桌面应用程序。该程序

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.batC:\Program Files\Java\jdk1.7.0_03\db\bin 开始,这可以正常工作。

但是如何自动启动那个bat文件呢?

4

0 回答 0