private boolean jButtonactionPerformed(ActionEvent e) {
try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:ds;DatabaseName=uubird";
Connection con=DriverManager.getConnection(url,"sa","asd");
java.sql.Statement pst=con.createStatement();
String yh=jTextField.getText();
String pw=new String(jPasswordField.getPassword());
String sql="select * from addressbook where yonghu='"+yh+"'and password='"+pw+"'";
System.out.println(sql);
ResultSet rs =pst.executeQuery(sql);
boolean dd=rs.next();
try{
if(dd){
for(int i=1;i<3;i++)
{
// System.out.println(rs.getString(i+1));
/*在以下程序总是运行错误!值rs.getString(i+1)赋值不进去asd[i];
说报错,不知道这个是怎么回事?!!高手帮帮忙啦
*/
asd[i]=rs.getString(i+1);
System.out.println( asd[i]+"==================");
}
//System.out.println(rs.getDate(4));
asd[3]=rs.getDate(4).toString();
for(int j=4;j<7;j++)
{ asd[j]= rs.getString(j+1);
}
}
}catch(Exception e1e)
{
System.out.println("===============zhe li cuo la =======================");
}
if(dd){
pst.close();
con.close();
zzdd.this.dispose();
return true;}
}catch(Exception ee)
{
JOptionPane.showMessageDialog(this, "登入失败!","登入",JOptionPane.INFORMATION_MESSAGE);
}
return false;
}
自己想的结论 rs.getString(i)只可以用一次!!两次就不可以啦
哈哈。。。没想到是自己先想出来啦。。
不过具体为什么这样,还是不懂耶!!