问题如图输出结果在eclipse上输出了,可是在文本框上出不来publicvoidquery(Stringsqls){Chaxunchaxun1=newChaxun();try{stmt=dbConn.createStatement();ResultSetrset=stmt.executeQ...
问题如图
输出结果在eclipse上输出了,可是在文本框上出不来
public void query(String sqls)
{
Chaxun chaxun1=new Chaxun();
try{
stmt=dbConn.createStatement();
ResultSet rset=stmt.executeQuery(sqls);
while(rset.next())
{
chaxun1.nameField4.setText(rset.getString(1));
chaxun1.nameField5.setText(rset.getString(2));
chaxun1.nameField6.setText(rset.getString(3));
chaxun1.nameField7.setText(rset.getString(4));
chaxun1.nameField8.setText(rset.getString(5));
for(int i=1;i<=5;i++) {
System.out.print(rset.getString(i)+"\t");
}
System.out.println();
}
这是我数据库类里的查询相关代码
public void actionPerformed(ActionEvent e){
if(e.getSource()==b1){
String name=nameField3.getText();
S s=new S();
operatedb op1=new operatedb("sa","85791469");
String s1="select * from st1 where name='"+name+"'";
op1.query(s1);
}
}
这是我查询类里的代码
求解 急急急 坐等答案
展开