3 messages in org.postgresql.pgsql-jdbcPreparedStatement clearParameters and...
FromSent OnAttachments
Akira SatoJul 24, 2006 6:42 pm 
Kris JurkaJul 25, 2006 11:57 am.patch
Kris JurkaAug 6, 2006 11:04 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:PreparedStatement clearParameters and setTimestampActions...
From:Akira Sato (sato@oss.ntt.co.jp)
Date:Jul 24, 2006 6:42:31 pm
List:org.postgresql.pgsql-jdbc

Hi,

This reply is about the following threads. http://archives.postgresql.org/pgsql-jdbc/2006-02/msg00156.php

With case of setTimestamp(), it seem to always do "Parse". (setDate() and setTime() too)

JDBC driver : 8.1-407 URL parameter : prepareThreshold=1&loglevel=2

sample code :

create table test(id int, tm timestamp);

int n = 10; Timestamp tm = new Timestamp(System.currentTimeMillis()); PreparedStatement pst = conn.prepareStatement("INSERT INTO test(id, tm) VALUES (?, ?)"); for(int i=0; i< n; i++){ pst.clearParameters(); pst.setInt(1, i); pst.setTimestamp(2, tm); pst.executeUpdate(); } pst.close()

----

When we used poolPreparedStatements (common-dbcp), a similar problem seems to occur. When we called close() of PreparedStatement, dbcp side calls clearParameters().

JDBC driver : 8.1-407 URL parameter : prepareThreshold=1&loglevel=2 Jakarta commons : commons-dbcp-1.2.1 commons-pool-1.3 commons-collections-3.2

sample code :

import org.apache.commons.dbcp.BasicDataSource; : String url = "jdbc:postgresql://localhost/testdb?loglevel=2&prepareThreshold=1"; BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("org.postgresql.Driver"); ds.setUsername("user"); ds.setPassword("passwd"); ds.setUrl(url); ds.setPoolPreparedStatements(true);

Connection conn = ds.getConnection();

int n = 10; Timestamp tm = new Timestamp(System.currentTimeMillis()); for(int i=0; i< n; i++){psql tes PreparedStatement pst = conn.prepareStatement("INSERT INTO test(id, tm) VALUES (?, ?)"); pst.setInt(1, i); pst.setTimestamp(2, tm); pst.executeUpdate(); pst.close() }

----

best regards,

Akira.