开发者社区> 问答> 正文

多个项目使用同一个数据库?报错

@wenshao 你好,想跟你请教个问题:

我在使用多个项目访问同一个数据库时,启动第二个项目会报错。

2016-01-14 16:40:48
 [] [] [ERROR]-[Thread: localhost-startStop-1]-[com.alibaba.druid.pool.DruidDataSource.init()]: init datasource error, url: jdbc:postgresql://192.168.6.97:5432/project2
org.postgresql.util.PSQLException: 尝试连线已失败。
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:257)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:159)
	at org.postgresql.Driver.makeConnection(Driver.java:416)
	at org.postgresql.Driver.connect(Driver.java:283)
	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:148)
	at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:785)
	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
	at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:211)
	at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:142)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1388)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1442)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:632)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:934)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:930)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:102)
	at com.jfinal.plugin.activerecord.TableBuilder.build(TableBuilder.java:80)
	at com.jfinal.plugin.activerecord.ActiveRecordPlugin.start(ActiveRecordPlugin.java:171)
	at com.jfinal.core.Config.startPlugins(Config.java:87)
	at com.jfinal.core.Config.configJFinal(Config.java:48)
	at com.jfinal.core.JFinal.init(JFinal.java:65)
	at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4574)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5193)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Illegal UTF-8 sequence: byte 2 of 2 byte sequence is not 10xxxxxx: -62
	at org.postgresql.core.UTF8Encoding.checkByte(UTF8Encoding.java:28)
	at org.postgresql.core.UTF8Encoding.decode(UTF8Encoding.java:103)
	at org.postgresql.core.PGStream.ReceiveString(PGStream.java:329)
	at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:424)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203)
	... 33 more



我使用的数据库是postgresql  ,请问如何配置 druid 能使得多个项目访问同一个数据库不报错。

展开
收起
爱吃鱼的程序员 2020-06-10 15:01:03 1013 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    <imgsrc="http://www.oschina.net/js/ke/plugins/emoticons/images/10.gif"alt=""> 数据库的配置是什么解决了连接池配置问题连接数配的太大了

    2020-06-10 15:01:20
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
DTCC 2022大会集锦《云原生一站式数据库技术与实践》 立即下载
阿里云瑶池数据库精要2022版 立即下载
2022 DTCC-阿里云一站式数据库上云最佳实践 立即下载