我想显示在jtable中一一保存数据的特定数据,但是从不显示所有数据,
private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {
String txt = jTextField1.getText().toString();
Connection cn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
cn = Dataconnection.getConnection();
qr = "SELECT p.ProductCode,p.ProductName, p.ProductPrice FROM
customer.product p WHERE CONCAT(p.ProductCode, p.ProductName) LIKE '%"+txt+"%'";
ps=cn.prepareStatement(qr);
ps.setString(1, jTextField1.getText());
rs=ps.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
rs.close();
ps.close();
} catch (Exception e) {
}
}
}