|
在jsp中用bean和servlet联合实现用户注册、登录(5) return false; } }
//判断结果集中是否有数据 public boolean hasData() { try{ boolean has_Data = this.rs.first(); this.rs.beforeFirst(); return has_Data; }catch(SQLException e){ System.out.println(e.toString()); return false; } }
public boolean rs_last() { try{ return this.rs.last(); }catch(SQLException e){ System.out.println(e.toString()); return false; } }
public boolean rs_previous() { try{ return this.rs.previous(); }catch(Exception e){ System.out.println(e.toString()); return false; } }
//main方法,调试用 public static void main(String args[]) { try{ DBConn myconn = new DBConn(); //myconn.setDBName("shopping"); //myconn.DBConn(); //myconn.execute("Insert Into tbl_test(id,name) values('10','shandaer')"); //myconn.execute("Update tbl_test set name='yyyyyyyyyyyy' where id=10"); //myconn.execute("Delete from tbl_test where id=1"); ResultSet rs = myconn.executeQuery("select * from tbl_user order by id desc limit 1"); //boolean hasData = myconn.hasData(); //System.out.println("has data:" + hasData); //rs.first(); while (myconn.rs.next()) { int id = myconn.rs_getInt("id") + 1; System.out.print(id); System.out.println(myconn.rs_getInt("id") + myconn.rs_getString("name"));
|