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
|
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.
|
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>
|
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.
|