我正试图使用MySQL在数据库中执行一个查询
PreparedStatement
ResultSet
.
问题是我在MySQL中得到的结果集是空的,否则我在Derby上得到的结果是正确的。
Connection con= null;
ResultSet reslt =null;
PreparedStatement ps = null;
try
{
//Class.forName("org.apache.derby.jdbc.ClientDriver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/SAIID","SAIID","SAIID");
//con = DriverManager.getConnection("jdbc:derby://localhost:1527/pavillons","saiid","saiid");
String Query =" SELECT * FROM ETUDIANT_PAV WHERE PAVILLONS = ? AND CHAMBRE = ? "
ps = con.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ps.setString(1, "A");
ps.setString(2, "1");
reslt = ps.executeQuery();
//String thequeryresult= reslt.getString("NOM_PRENOM");
//System.out.println ("this is the query result"+thequeryresult);
JOptionPane.showMessageDialog(null, "Query Executed");
//con.close();
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null, ex.getMessage());
}