java表格模糊查询_在Java中从表中得到数据怎么进行模糊查询然后在表中显示

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();

}

}

});

就是在表中得不到结果,不知道哪里错了

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值