Re: Opening db connections



Lew wrote:
What is StatementProvider?

Eduardo Yáñez Parareda wrote:
I'm sorry, it's a class of my project, I didn't realize of that.

This is what I meant:

Connection conn = .... getConnection...

Statement stmt = conn.getStatement();
ResultSet rs = stmt.executeQuery("select 1");
rs = stmt.executeQuery("select 1");
rs = stmt.executeQuery("select 1");

You have as many connections as conn points to.
<http://java.sun.com/javase/6/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String)>

<http://java.sun.com/javase/6/docs/api/java/sql/Connection.html>

and, of course, the Javadocs for ResultSet and Statement.

BTW, consider using a PreparedStatement instead of a "regular" Statement.

--
Lew
.



Relevant Pages

  • RE: ## Global Temp Tables and "invalid object name" error via JDBC
    ... Connection conn = null; ... Statement stmt = null; ... PreparedStatement pstmt = null; ... t.dtyTypeString FROM tblDocumentRepository d INNER JOIN tblDocumentTypes t ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: JDBC SQL2005 Read encripting fields problem
    ... Joe Weinstein wrote: ... Statement stmt = con.createStatement; rs = stmt.executeQuery; ... When I run the query in the Query Analizer it return a correct value, but when I run mi java aplication it return a null resultSet. ... String sql = "select usuario " ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Problem with actualization
    ... When I show these strings on the strings I got: ... public static void executeQuery(String query) { ... Statement stmt; ... public static ResultSet getQueryResult{ ...
    (comp.lang.java.databases)
  • Re: [JSP] 2 nested result set
    ... String query_1; ... ResultSet rs1 = stmt.executeQuery; ... The answers are so often in the Javadocs, and one expects that would be the first place one would look. ... The JSTL has a rich set of SQL tags that would save you using a DAO layer, which seems a suitable shortcut for your application. ...
    (comp.lang.java.programmer)
  • closing java.sql.Statements
    ... Connection conn = null; ... Statement stmt = null; ... ResultSet rset = null; ...
    (comp.lang.java.programmer)