Skip to content

Instantly share code, notes, and snippets.

@and0
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save and0/9594530 to your computer and use it in GitHub Desktop.
Save and0/9594530 to your computer and use it in GitHub Desktop.

TEST ONE

$ java -jar pyx-test.jar -dbcp

DB type: PostgreSql ConnectionPool:dbcp
Mar 17, 2014 12:57:37 AM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Mar 17, 2014 12:57:39 AM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
Exception in thread "main" java.lang.Error: try# 4; hour of 2014-03-09 07:21:28.0 expected 6 but was 7
	at com.pyx4j.entity.rdb.poc.dls.DaylightSavingJDBC.main(DaylightSavingJDBC.java:262)

TEST TWO

$ java -jar pyx-test.jar -c3p0

DB type: PostgreSql ConnectionPool:c3p0
table already exists? org.postgresql.util.PSQLException: ERROR: relation "test123" already exists
Mar 17, 2014 12:58:25 AM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
Mar 17, 2014 12:58:33 AM com.mchange.v2.c3p0.C3P0Registry banner
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
Mar 17, 2014 12:58:35 AM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFO: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge136901l9q0nttlcimk|4ab9a144, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.postgresql.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge136901l9q0nttlcimk|4ab9a144, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:postgresql://localhost/tst_entity, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 5, maxStatements -> 200, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
Exception in thread "main" java.lang.Error: try# 8; hour of 2014-03-09 07:21:28.0 expected 6 but was 7
	at com.pyx4j.entity.rdb.poc.dls.DaylightSavingJDBC.main(DaylightSavingJDBC.java:262)

OS

ProductName: Mac OS X ProductVersion: 10.7.5 BuildVersion: 11G63b

JAVA

Java(TM) SE Runtime Environment (build 1.7.0_51-b13) Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

POSTGRES

postgresql: stable 9.3.3 (bottled) http://www.postgresql.org/ Conflicts with: postgres-xc /usr/local/Cellar/postgresql/9.3.3 (2923 files, 39M) * Poured from bottle From: https://github.com/mxcl/homebrew/commits/master/Library/Formula/postgresql.rb

@polobo
Copy link

polobo commented Mar 17, 2014

The PostgreSQL JDBC driver begins using named prepared statements after 5 successive executions of the same prepared statement on a given connection/session. The time to failure thus relies on the presence of pool and its specific behavior and configuration. You could also just not continually issue "con2.prepareStatement(...)" and instead reuse the first prepared statement object multiple times. Note - for the test writer - it is less confusing, when counting "tries", to number them starting with 1...just saying...

@skarzhevskyy
Copy link

Confirmed
on 5th successive executions of the same prepared statement on a given connection the problem manifests it self.

https://github.com/skarzhevskyy/pgjdbc/blob/master/org/postgresql/test/other/PreparedStatementDaylightSavingTest.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment