似乎與Statement st = conn.createStatement();
這裏的問題是我的代碼:爲什麼Netbeans在createStatement()中爲MySQL數據庫連接顯示錯誤?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel model=(DefaultTableModel)p1.getModel();
try{
Class.forName("java.sql.Driver");
Connection conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/product","root","");
Statement st = conn.createStatement();
String query="Select*from voltron;";
ResultSet rs=st.executeQuery(query);
while(rs.next()) {
String s1=rs.getString("id");
String s2=rs.getString("product");
String s3=rs.getString("brand");
String s4=rs.getString("price");
String s5=rs.getString("release");
model.addRow(new Object[]{s1,s2,s3,s4,s5});
}
rs.close();;
st.close();
conn.close();
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, "There is an ERROR");
}
}
它顯示的問題是...? – 2014-12-07 20:44:56
它顯示沒有默認的createStatement()方法,並顯示「無法找到符號」,並顯示創建新方法createStatement() – 2014-12-07 20:48:35
請將* exact *和完整的錯誤消息放入問題中。 – 2014-12-07 20:50:02