Mateusz
unread,Aug 2, 2009, 2:57:33 PM8/2/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to H2 Database
Hi folks,
i have a strange problem with my H2 database with url:
jdbc:h2:tcp://localhost/myDB
I've been using following configuration ofspring data source for
almost 7 months and it worked pretty well:
<bean id="myDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="${myDB.jdbc.driverClassName}" p:url="$
{myDB.jdbc.url}"
p:username="${myDB.jdbc.username}" p:password="$
{myDB.jdbc.password}" />
Unfortunately, it occured that DriverManagerDataSource is not pooled,
so i decided to switch to c3p0 and following conf:
<bean id="myDataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-
method="close"
p:driverClass="${myDB.jdbc.driverClassName}" p:jdbcUrl="$
{myDB.jdbc.url}"
p:user="${myDB.jdbc.username}" p:password="${myDB.jdbc.password}"
p:minPoolSize="${myDB.jdbc.minPoolSize}" p:initialPoolSize="$
{myDB.jdbc.initialPoolSize}" p:maxPoolSize="${myDB.jdbc.maxPoolSize}" /
>
Despite the total mismatch between conf parameters (why the hell there
must by user/username or driverClass/driverClassName - it really makes
mistakes), c3p0 cannot make pooled connection to DB because H2 throws
Invalid username/password. I'm sure user/pass (for me sa/sa) is good
and even if I return to previous configuration with
DriverManagerDataSource, everything works fine.. Of course, even if I
log throught H2 Web Console using same url and sa/sa - I'm
successfully logged in and I can browse my DB.
What's more interesting, when I leave password blank, spring seems to
lock on line:
[2009-08-02 20:47:21.001]INFO [ContainerBackgroundProcessor
[StandardEngine[Catalina]]][AbstractPoolBackedDataSource] 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 ->
1hge160821p5vwnl1huyl8u|2665745, debugUnreturnedConnectionStackTraces -
> false, description -> null, driverClass -> org.h2.Driver,
factoryClassLocation -> null, forceIgnoreUnresolvedTransactions ->
false, identityToken -> 1hge160821p5vwnl1huyl8u|2665745,
idleConnectionTestPeriod -> 0, initialPoolSize -> 1, jdbcUrl ->
jdbc:h2:tcp://localhost/myDB, maxAdministrativeTaskTime -> 0,
maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -
> 0, maxPoolSize -> 1, maxStatements -> 0, maxStatementsPerConnection -
> 0, minPoolSize -> 1, numHelperThreads -> 3,
numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery ->
null, properties -> {user=******, password=******}, propertyCycle ->
0, testConnectionOnCheckin -> false, testConnectionOnCheckout ->
false, unreturnedConnectionTimeout -> 0,
usesTraditionalReflectiveProxies -> false ]
And after 2m30sec throws:
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException:
A ResourcePool could not acquire a resource from its primary factory
or source.
Seem like there is something wrong between H2 and c3p0 or my
configuration (driver? url?) is wrong.
Thanks in advance for any suggestions!
Matthew