-3

这是显示错误的代码:这是连接我的测试数据库并在其中创建名为 r 的表的 Netbeans 代码

try{
  Class.forName("java.sql.Driver");
  Connection con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","tiger");
  Statement stmt =con.createStatement();
  String query = "create table r(s int);";
  ResultSet rs = stmt.executeQuery(query);
  this.dispose();
  roll second = new roll(); 
  second.setVisible(true);
} catch (Exception e) {
  lbl1.setText("Error1 in database connectivity");
}
4

1 回答 1

1
ResultSet rs = stmt.executeQuery(query);

改为使用

 stmt.executeUpdate(query);
于 2013-06-25T04:05:19.847 回答