Advertisement
Guest User

Untitled

a guest
Mar 17th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. psycopg2.connect(...).cursor().execute("select * from account where id='00100000006ONCrAAO'")
  2.  
  3. 2011-07-18 18:56:08 PDT LOG: duration: 6.112 ms statement: select * from account where id='00100000006ONCrAAO'
  4.  
  5. conn.createStatement().executeQuery("select * from account where id = '00100000006ONCrAAO'");
  6.  
  7. 2011-07-18 18:44:59 PDT LOG: duration: 4.353 ms parse <unnamed>: select * from account where id = '00100000006ONCrAAO'
  8. 2011-07-18 18:44:59 PDT LOG: duration: 0.230 ms bind <unnamed>: select * from account where id = '00100000006ONCrAAO'
  9. 2011-07-18 18:44:59 PDT LOG: duration: 0.246 ms execute <unnamed>: select * from account where id = '00100000006ONCrAAO'
  10.  
  11. private PreparedStatement preparedStatement;
  12.  
  13. public ResultSet getAccount(String id) throws SQLException {
  14. // Do this once
  15. if (preparedStatement == null)
  16. preparedStatement = conn.prepareStatement("select * from account where id = ?");
  17.  
  18. // Do this many times
  19. preparedStatement.setString(1, id);
  20. return preparedStatement.executeQuery();
  21. }
  22.  
  23. public static void main(String[] args) throws Exception {
  24. ResultSet rs = new MyClass().getAccount("00100000006ONCrAAO");
  25. }
  26.  
  27. prepareThreshold=0
  28.  
  29. jdbc:postgresql://db.address/dbName?prepareThreshold=0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement