private void search_fKeyReleased(java.awt.event.KeyEvent evt) {
try {
这里有点不对劲
PreparedStatement pst =null;
ResultSet rst=(ResultSet) pst;
Connection con=(Connection)
DriverManager.getConnection("jdbc:mysql://localhost/iqari",
"root","");
String sql="select * from first where masaha_iqar=?";
pst=(PreparedStatement) con.prepareStatement(sql);
pst.setString(1,search_f.getText());
rst=pst.executeQuery();
在文本区域我得到的结果而不是我的数据库中的两个
if (rst.next()){String add1=rst.getString("raqm_iqar");
jTextArea2.append(add1 + "\n");
System.out.format("%s",add1);
}
} catch (Exception e) {
}
TODO add your handling code here:
}
答案 0 :(得分:0)
try {
PreparedStatement pst =null;
ResultSet rst=(ResultSet) pst;
Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost/iqari", "root","");
String sql="select * from first where masaha_iqar=?";
pst=(PreparedStatement) con.prepareStatement(sql);
pst.setString(1,search_f.getText());
rst=pst.executeQuery();
while (rst.next()){String add1=rst.getString("raqm_iqar");
jTextArea2.append(add1 + "\n");
System.out.format("%s",add1);
}
} catch (Exception e) {
}