List:MySQL and Java« Previous MessageNext Message »
From:Filip Rachunek Date:May 19 2003 9:36am
Subject:Query flow
View as plain text  
Hello,
I would like to ask which way of using JDBC code in one servlet is better:

1)
Connection con = pool.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query1);
...
rs.close();
...
rs = stmt.executeQuery(query2);
...
rs.close();
...
rs = stmt.executeQuery(query3);
...
rs.close();
stmt.close();
pool.closeConnection();

2)
Connection con = pool.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query1);
...
rs.close();
stmt.close();
pool.closeConnection();
...
con = pool.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(query2);
...
rs.close();
stmt.close();
pool.closeConnection();
...
con = pool.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(query3);
...
rs.close();
stmt.close();
pool.closeConnection();

Does anybody have expriences with that and can provide some comparation?

Thanks.
Filip

http://BrainKing.com
http://BrainKing.info

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* 
http://join.msn.com/?page=features/virus

Thread
Query flowFilip Rachunek19 May
  • delete datareid19 May
    • Re: delete dataPaul DuBois19 May
  • Re: delete dataChristopher Taylor19 May
  • Re: delete datareid19 May
  • sort ascendingreid19 May
  • installation mysqlreid22 May
    • Re: installation mysqlDave Newton23 May
Re: sort ascendingAndreas Schyman20 May