我在下面发布了日志的一小部分,如果有人可以解码以下内容,我将非常感激:
我有以下 C3PO 配置:
c3p0.minPoolSize=10
c3p0.maxPoolSize=40
c3p0.acquireIncrement=5
c3p0.maxIdleTime=1800
c3p0.maxStatements=50
c3p0.idleConnectionTestPeriod=180
Run Code Online (Sandbox Code Playgroud)
这是日志:
09-02@12:28:43 WARN ThreadPoolAsynchronousRunner [Timer-0] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@700ec336 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
09-02@12:28:43 WARN ThreadPoolAsynchronousRunner [Timer-0] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@700ec336 -- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@34ac7f2c (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@28d13cb8 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0)
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@40e968f7 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2)
Pending Tasks:
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@1bea516c
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@348797c5
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@31fd2174
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@619f604f
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@266c149b
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@1bcdfd2
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@170a54e2
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@274acd3f
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@1fe8f740
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@77c09b1d
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@607ca57
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@697518d8
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@6b242ff
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@214c76c8
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@230a558c
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask@7b766c4c
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@1bc030e7
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@66ca9bec
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@7fc2d7ac
com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StatementCloseTask@50dd9ebb …
Run Code Online (Sandbox Code Playgroud) Hibernate 4使用jdbc4,将方法setBinaryStream(int,InputStream,int)的签名更改为setBinaryStream(int,InputStream,long).C3P0不支持这种新方法.
因此调用saveOrUpdate(myObjWithBlob)结果
java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy75.setBinaryStream(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
那我现在该怎么办?
1)不要使用c3p0.DHCP,BoneCP或根本没有连接池. - 真的不是我想要的选择.
2)以某种方式让hibernate避免调用这个新方法?有可能吗?
3)切换回休眠3 - 对我来说也不是很好.
在我的Javafx应用程序中,我使用sftp连接到Hetzner.de上的远程服务器.为了管理连接,我使用cp30库连接池与以下参数:
public Connection dbConnectSite() throws SQLException, PropertyVetoException {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("com.mysql.jdbc.Driver");
cpds.setJdbcUrl("jdbc:mysql://" + mySQLHost + ":" + mySQLPort + "/" + mySQLDBName + "?characterEncoding=UTF-8&autoReconnect=true"); // 192.168.100.100 v seti.
cpds.setUser(mySQLUser);
cpds.setPassword(mySQLPassword);
cpds.setMinPoolSize(3);
cpds.setMaxPoolSize(20); // Maximum number of Connections a pool will maintain at any given time.
cpds.setAcquireIncrement(1);
cpds.setTestConnectionOnCheckin(true); // If true, an operation will be performed asynchronously at every connection checkin to verify that the connection is valid.
cpds.setTestConnectionOnCheckout(true); // If true, an operation will be performed at …
Run Code Online (Sandbox Code Playgroud) 就我而言,对于测试连接,c3p0通过执行查询花费了太多时间
SHOW FULL TABLES FROM `xyz` LIKE 'PROBABLYNOT'
Run Code Online (Sandbox Code Playgroud)
而我使用的是mysql连接器版本5.1.25.有驱动程序支持JDBC 4.我提到了一个链接 http://www.mchange.com/projects/c3p0/#configuring_connection_testing
提到的地方
如果您使用的JDBC驱动程序肯定支持新的(ish)JDBC 4 API,则不执行任何操作.JDBC 4 Connections包含一个名为isValid()的方法,该方法应实现为快速,可靠的连接测试.默认情况下,c3p0将使用该方法(如果存在).
所以我的问题是我是如何知道它是使用isvalid()方法以及当c3p0调用此方法时执行的查询.
我正在使用移动Web应用程序,对于我正在使用的数据库部分Hibernate
和连接池c3p0
,当我在开始运行应用程序时它工作正常,但在做了一些事务,如选择,保存,更新,我得到以下异常,我不知道为什么会发生这种情况,
Sep 22, 2015 12:40:06 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already. Could not load com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1562)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:1040)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1507)
at com.mchange.v2.resourcepool.BasicResourcePool.removeResource(BasicResourcePool.java:1477)
at com.mchange.v2.resourcepool.BasicResourcePool.cullExpired(BasicResourcePool.java:1565)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1900(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$CullTask.run(BasicResourcePool.java:2089)
at java.util.TimerThread.mainLoop(Timer.java:512)
at …
Run Code Online (Sandbox Code Playgroud) 我得到了这个 Java Web 应用程序,它恰好与 SQL Server 数据库进行了过多的通信。我想决定如何以有效的方式管理与该数据库的连接。我想到的第一个选项是使用第三方连接池。我选择了C3P0和DBCP,并准备了一些测试用例来比较这些方法,如下所示:
无池化:
public static void main(String[] args) {
long startTime=System.currentTimeMillis();
try {
for (int i = 0; i < 100; i++) {
Connection conn = ConnectionManager_SQL.getInstance().getConnection();
String query = "SELECT * FROM MyTable;";
PreparedStatement prest = conn.prepareStatement(query);
ResultSet rs = prest.executeQuery();
if (rs.next()) {
System.out.println(i + ": " + rs.getString("CorpName"));
}
conn.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Finished in: "+(System.currentTimeMillis()-startTime)+" milli secs");
}
Run Code Online (Sandbox Code Playgroud)
二氯苯酚:
public static …
Run Code Online (Sandbox Code Playgroud)