Guest User

Untitled

a guest
Jun 13th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Connection con;
  2. ResultSet rs;
  3. PreparedStatement ps;
  4. try
  5. {
  6. con = this.pool.getConnection();
  7. ps = con.prepareStatement("INSERT INTO users(id, login,password)VALUES(DEFAULT,?,?) RETURNING id");
  8. Assert.assertNotNull("could not create prepared statement", ps);
  9. ps.setString(1, "benuasdfaewftzerasdfnameasdf");
  10. ps.setString(2, "passwort");
  11. rs = ps.executeQuery();
  12. Assert.assertNotNull("could not execure query", rs);
  13. Assert.assertTrue("there wherent any generated keys..", rs.next());
  14. System.out.print(rs.getInt("id"));
  15. Assert.assertFalse(rs.next());
  16. }
  17. catch(SQLException e)
  18. {
  19. // TODO Auto-generated catch block
  20. e.printStackTrace();
  21. }
Add Comment
Please, Sign In to add comment