public static boolean addUser(String username,String password){
PreparedStatement pst=null;
conn=getConnection();
try {
conn.setAutoCommit(true);
pst=conn.prepareStatement("select * from person where username=?");//这里也不成功
pst.setString(1, username);
ResultSet res=pst.executeQuery();
if(res.next())
{
return false;
}
pst.close();
pst=conn.prepareStatement("insert into person values(?,?)");
pst.setString(1, username);
pst.setString(2, password);
pst.executeQuery();
return true;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}