JButtonchaxun=newJButton("\u6A21\u7CCA\u67E5\u8BE2");chaxun.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventarg0){Stringname=textyhm.getText();...
JButton chaxun = new JButton("\u6A21\u7CCA\u67E5\u8BE2");
chaxun.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String name=textyhm.getText();//得到用户名重的要查询的内容
String pwd=textmima.getText();//得到密码框要查询的内容
String sqlIns="select * from biao2 where username like '%"+name+"%'"+"or password like '%"+pwd+"%'";
try{
ResultSet rs=null;
dftm.setDataVector(null, columnNames);//表
Connection dbconn=Conn.getCon();
Statement stmt=dbconn.createStatement();
rs=stmt.executeQuery(sqlIns);//得到经过查询后的结果集
while (rs.next())
{
String id = String.valueOf(rs.getInt(1));
String name1 = rs.getString(2);
String pwd1 = rs.getString(3);
String[] biao2 = { id, name1, pwd1 };
dftm.addRow(biao2);//得到的结果添加到表中去
}
initTable();
stmt.close();
dbconn.close();
}
catch(SQLException r)
{r.printStackTrace();
}
}
});
就是在表中得不到结果,不知道哪里错了
展开