> when the connection to a DB is open, when you get the Statement or when
> you execute it?
When you issue a DriverManager.getConnection(), typically, or via the
javax.persistence.EntityManager class.
> ie.:
>
[quoted text clipped - 4 lines]
>
> Does this code mean 3 opened connection or only one (getStatement)?
It's no more than one, but not being familiar with the StatementProvider class
it's hard to be sure.
What is StatementProvider?

Signature
Lew
Eduardo Yáñez Parareda - 13 Nov 2007 14:17 GMT
> It's no more than one, but not being familiar with the StatementProvider
> class it's hard to be sure.
>
> What is StatementProvider?
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");
Lew - 13 Nov 2007 14:31 GMT
Lew wrote:
>> What is StatementProvider?
> I'm sorry, it's a class of my project, I didn't realize of that.
>
[quoted text clipped - 6 lines]
> 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.

Signature
Lew