HXTT DBF
PreparedStatement and connection pooling
Dewil Maxence
2005-05-02 00:00:00.0
Hi,

I updated my application to use the DBCP connection pool as documented in your online documentation.

It seems the PreparedStatement does not work with the connection pool when it is filled with parameters.

The following exception is thrown: java.sql.SQLException: Please set value for parameter 1.

When I execute the same sql query on an unpooled connection with the same parameters in the PreparedStatement, it works.

Any idea of what is the cause?

Thx
Re:PreparedStatement and connection pooling
HXTT Support
2005-05-10 00:00:00.0
Hi,I have tested and not found any problem.
The follows is the datasource configuration part in the server.xml .


factory
com.hxtt.sql.HxttObjectFactory


subprotocol
DBF



database
f:/DBFfiles



And here is my code in my jsp file.
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds1 = (DataSource) envContext.lookup("jdbc/testDBFPool3");
Connection conn1 = ds1.getConnection();
out.println("testDBFPool1 OK:)
");
PreparedStatement stmt1 = conn1.prepareStatement("select * from test where testfield=?");
stmt1.setString(1,"644");
ResultSet rs1 = stmt1.executeQuery();
while (rs1.next())
out.println(rs1.getString(1) + ":)
");

You can download the latest HXTT Package to solve this issue.
Re:Re:PreparedStatement and connection pooling
HXTT Support
2005-05-10 00:00:00.0
Sorry,this configuration is error.

<Resource name="jdbc/testDBFPool3" auth="Container" type="com.hxtt.sql.HxttConnectionPoolDataSource"/> 

<ResourceParams name="jdbc/testDBFPool3">

<parameter>

<name>factory</name>

<value>com.hxtt.sql.HxttObjectFactory</value>

</parameter> 

<parameter>

<name>subprotocol</name>

<value>DBF</value>

</parameter> 



<parameter>

<name>database</name> 

<value>f:/DBFfiles</value>

</parameter>

</ResourceParams>

Re:Re:Re:PreparedStatement and connection pooling
Dewil Maxence
2005-06-08 00:00:00.0
Hi,

the problem was caused by a copy-paste mistake:
what I have made:
PreparedStatement pStmt = connection.prepareStatement(myQuery);
//.. populate the parameters
pStmt.executeQuery(myQuery);
//.. PreparedStatement extends Statement

So I suppose the query is parsed twice..

Sorry for my previous post.

Thx.


Google