问题描述
我将Sybase ASE与Hibernate-core 4.2.8.Final,hiberante-c3po 4.2.8.Final,hibernate-search 4.4.2.Final
I'm using Sybase ASE with Hibernate-core 4.2.8.Final, hiberante-c3po 4.2.8.Final, hibernate-search 4.4.2.Final
我的hibernate.cfg.xml文件看起来像这样
My hibernate.cfg.xml file looks like so
<property name="hibernate.connection.driver_class">com.sybase.jdbc4.jdbc.SybDataSource</property>
<property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="hibernate.connection.url">jdbc:sybase:Tds:server:5000/dev</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.idle_test_period">1800</property>
<property name="hibernate.c3p0.timeout">3600</property>
当我添加hibernate.c3p0时,我得到以下SQLWarning,但是当我删除它时,例外消失了。没有人知道如何摆脱警告或defaultdb的来源吗?
When I add in hibernate.c3p0 I get the following SQLWarning, but when I remove it, the exception goes away. Does anybody know how to get rid of the warning or where the defaultdb is coming from?
c3p0.SQLWarnings Server user id 29 is not a valid user in database 'defaultdb'
java.sql.SQLWarning: Server user id 29 is not a valid user in database 'defaultdb'
at com.sybase.jdbc4.jdbc.SybConnection.convertToWarnings(SybConnection.java:2893)
at com.sybase.jdbc4.jdbc.SybConnection.chainWarnings(SybConnection.java:2909)
at com.sybase.jdbc4.tds.Tds.processLoginAckToken(Tds.java:5125)
at com.sybase.jdbc4.tds.Tds.doLogin(Tds.java:724)
at com.sybase.jdbc4.tds.Tds.login(Tds.java:578)
at com.sybase.jdbc4.jdbc.SybConnection.tryLogin(SybConnection.java:415)
at com.sybase.jdbc4.jdbc.SybConnection.handleHAFailover(SybConnection.java:3226)
at com.sybase.jdbc4.jdbc.SybConnection.<init>(SybConnection.java:341)
at com.sybase.jdbc4.jdbc.SybConnection.<init>(SybConnection.java:248)
at com.sybase.jdbc4.jdbc.SybDriver.connect(SybDriver.java:233)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)
at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)
c3p0.SQLWarnings Cannot open default database 'defaultdb'.
推荐答案
几乎可以肯定,无论您是否遇到警告,使用c3p0,但是c3p0对于定期检查Connections中的警告并记录它们非常挑剔。
You are almost certainly experiencing the warning regardless of whether you use c3p0, but c3p0 is very fussy about periodically checking Connections for warnings and logging them.
SQLWarnings
是通常不会抛出的异常对象。它们被链接到一个链表中,并与 Connection
对象相关联。在任何 Connection
上,都可以通过调用 myConnection.getWarnings()
来检查警告,并通过调用<$ c来清除警告。 $ c> myConnection.clearWarnings()。
SQLWarnings
are Exception objects that are typically never thrown. They are chained into a linked list and associated with Connection
objects. On any Connection
, you can check for warnings by calling myConnection.getWarnings()
and clear warnings by calling myConnection.clearWarnings()
.
在实践中,很少有应用程序需要检查和清除警告,但是c3p0可以,所以如果您的应用程序由于某种原因而生成警告,则在打开c3p0时会看到警告,但是如果没有它,它们似乎会消失。
In practice, very few applications bother to check for and clear warnings, but c3p0 does, so if your application is generating warnings for some reason, you'll see them when you turn c3p0 on, but they'll seem to disappear without it.
如果这很烦人而您想忽略警告,只需在使用的任何日志库中关闭记录器 com.mchange.v2.c3p0.SQLWarnings
的日志记录即可。
If this is annoying and you want to ignore warnings, just turn off logging for logger com.mchange.v2.c3p0.SQLWarnings
in whatever logging library you use.
如果您想了解这些警告而不是仅仅忽略它们,那么,您必须等待比我更了解Sybase的人来回答。
If you want to understand these warnings rather than just ignore them, well, you've have to wait for someone who knows Sybase better than I do to respond.
这篇关于c3p0.SQLWarnings服务器用户ID 29不是数据库'defaultdb'中的有效用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!