ResultSet 是个结果集.不能这样取记录的sql1.getString("psw");
需要循环历遍的.那怕结果集返回的只有一条记录
改成这样看看.
public static void main(String args[]) {
Connection conn;
conn = Conn.getCon();
try{
Statement stmt = conn.createStatement();
ResultSet sql1=stmt.executeQuery("select * from register where name='cai'");
while(sql1.next()){
String iping = sql1.getString("psw");
int porting=sql1.getInt("psw2");
System.out.println(iping);
System.out.println(porting);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("怎么会有错");
}
}