这是我的代码,显示错误: 这是Netbeans代码,用于连接我的测试数据库并在其中创建名为r
的表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");
}
答案 0 :(得分:1)
ResultSet rs = stmt.executeQuery(query);
改为使用
stmt.executeUpdate(query);