基本情况是:我有个需求是需要连接多个不同类型和不同实例的数据库去对比数据,但是前面两个数据源可以访问到,第三个就是不行,麻烦有碰到这种情况的大神释疑解惑一下,感激不尽
#database config dbType=mysql jdbcUrl = jdbc:mysql://10.1.1.8/jfinaldemo?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull user = root password =111111 devMode =true #This data is for BSERP3,the dbType is SqlServer dbType2 = SqlServer jdbcUrl2 = jdbc:sqlserver://218.16.212.43:8437;Database=BSERP3 user2 = sa password2 = HX&ftmz2018! driverClass2 = com.microsoft.sqlserver.jdbc.SQLServerDriver devMode2 = true #This data is for U8CLOUD,the dbType is SqlServer dbType3 = SqlServer jdbcUrl3 = jdbc:sqlserver://127.0.0.1:1433;Database=U8CLOUD user3 = sa password3 = sa driverClass3 = com.microsoft.sqlserver.jdbc.SQLServerDriver devMode3 = true
上面是配置文件,下面是java代码
@Override public void configPlugin(Plugins me) { //配置数据库连接池插件(Mysql数据源配置) C3p0Plugin c3p0Plugin=new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));//这里默认的是使用Mysql的Driver,所以这里不需要传Driver地址 System.out.println("****************************设置Mysql数据库连接池成功**************************************"); //orm映射 配置ActiveRecord插件 ActiveRecordPlugin arp=new ActiveRecordPlugin("mysql",c3p0Plugin);//当有多个数据源时,这里需要给每个数据源起别名 System.out.println("*******************************Mysql配置ActiveRecordPlugin成功***********************************"); arp.setShowSql(PropKit.getBoolean("devMode")); arp.setDialect(new MysqlDialect());//设置数据库方言,这里设置的是mysql的方言 System.out.println("***************************设置Mysql方言成功***************************************"); _MappingKit.mapping(arp);//设置主键映射 System.out.println("*****************************设置Mysql主键映射成功*************************************\n\n"); me.add(c3p0Plugin); me.add(arp); //SqlServer数据源配置(这个数据库是BSERP3的数据库) C3p0Plugin c3p0Plugin2=new C3p0Plugin(PropKit.get("jdbcUrl2"), PropKit.get("user2"), PropKit.get("password2"),PropKit.get("driverClass2")); System.out.println("****************************设置SqlServer1数据库连接池成功**************************************"); // DruidPlugin dpSqlserver2 = new DruidPlugin(" jdbc:sqlserver:// 218.16.212.43:8257;Database=BSERP3","sa"," HX&ftmz2018!","com.microsoft.sqlserver.jdbc.SQLServerDriver"); ActiveRecordPlugin arp2=new ActiveRecordPlugin("sqlserver1",c3p0Plugin2);//当有多个数据源时,这里需要给每个数据源起别名 System.out.println("*******************************SqlServer1配置ActiveRecordPlugin成功***********************************"); arp2.setShowSql(PropKit.getBoolean("devMode2")); arp2.setDialect(new SqlServerDialect()); System.out.println("***************************设置SqlServer1方言成功***************************************\n\n"); //_MappingKit.sqlServerMapping(arp2);//设置主键映射 me.add(c3p0Plugin2); me.add(arp2); //SqlServer数据源配置(这个数据库是U8CLOUD的数据库) C3p0Plugin c3p0Plugin3=new C3p0Plugin(PropKit.get("jdbcUrl3"), PropKit.get("user3"), PropKit.get("password3"),PropKit.get("driverClass3")); System.out.println("****************************设置SqlServer2数据库连接池成功**************************************"); ActiveRecordPlugin arp3=new ActiveRecordPlugin("sqlserver2",c3p0Plugin3);//当有多个数据源时,这里需要给每个数据源起别名 System.out.println("*******************************SqlServer2配置ActiveRecordPlugin成功***********************************"); arp3.setShowSql(PropKit.getBoolean("devMode3")); arp3.setDialect(new SqlServerDialect()); System.out.println("***************************设置SqlServer2方言成功***************************************"); //_MappingKit.sqlServerMapping(arp2);//设置主键映射 me.add(c3p0Plugin3); me.add(arp3); ActivitiPlugin acitivitiPlugin = new ActivitiPlugin();//工作流插件 ShiroPlugin shiroPlugin = new ShiroPlugin(this.routes);//Shiro插件 shiroPlugin.setLoginUrl("/admin/login");//登陆url:未验证成功跳转 shiroPlugin.setSuccessUrl("/admin/index");//登陆成功url:验证成功自动跳转 shiroPlugin.setUnauthorizedUrl("/admin/login/needPermission");//授权url:未授权成功自动跳转 //添加到插件列表中 me.add(acitivitiPlugin); me.add(shiroPlugin); }
然后报错:
2018-06-22 18:02:47,653 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@604bbc87 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 2018-06-22 18:02:47,663 WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@604bbc87 -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3 Active Threads: 3 Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2fbc54ef (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@756c2f64 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@119b8a76 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@7a9f5201 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@71c0fe8b com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@35879205 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@5783a1b7 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@2ee2244 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@600b9fdc com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@1b2c55c7 Pool thread stack traces: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) java.net.Socket.connect(Socket.java:579) com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:360) com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1034) com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833) com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716) com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] java.lang.Thread.sleep(Native Method) com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:876) com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716) com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) java.net.Socket.connect(Socket.java:579) com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:360) com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1034) com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833) com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716) com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
项目:JFinal
用排除法先解决一下,例如,删掉第二个库,只留第一和第三个库,也就是将第三个库当成第二个库用来,因为你前面讲了,你的第二个库是可以用的
再一个你的异常信息中没有 cause 部分,也没有 error , 只有 warn ,这个严格来说不是异常
将 c3p0 换成 DrudiPlugin 即可,具体用法在首页下载 jfinal demo 中的 druid 用法