2012-04-25 154 views
1

我在tomcat7上实现连接池时遇到问题。 由于某种原因,tomcat试图连接我的机器用户名。我已经googlin了一段时间,但没有运气。Tomcat上的连接池7

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory 
(FATAL: role "caspinol" does not exist) 
Cant connect to db 
Log In failed: An Exception has occurred! java.lang.NullPointerException 
java.lang.NullPointerException 
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)... 

我的context.xml如下所示:

<Resource auth="Container" name="jdbc/postgres" type="javax.sql.DataSource" user="biller" password="biller" 
      driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432" maxActive="150" 
      schema="biller" maxIdle="4"/> 

而且在web.xml:

<resource-ref> 
    <description>postgreSQL Datasource</description> 
    <res-ref-name>jdbc/postgres</res-ref-name> 
    <res-type>javax.sql.DataSource</res-type> 
    <res-auth>Container</res-auth> 
</resource-ref> 

我使用jdbc4.jar Postgres的驱动程序。 我很感激,如果有人可以看看,并指出什么是错误提前

感谢

+0

username =“biller”而不是user =“biller”? – 2012-04-25 16:44:04

+1

非常感谢。这解决了第一个问题......奇怪的是,这个配置实际上来自“Tomcat - 权威指南”。谨防这些书... :) – SneakyMummin 2012-04-26 08:55:33

回答

0

的URL似乎是错误的。 试试这个网址:

jdbc:postgresql://localhost:5432/<db_name> 

与实际的数据库名称替换<db_name>

+0

而这解决了其他:) – SneakyMummin 2012-04-26 08:55:53

0

这不是这个问题的正确解决方案,但会帮助有人用正确的连接字符串搜索相同的问题。

检查您的网络连接访问: 像连接字符串

jdbc:postgresql://[::1]:5432/<db_name> 

使用IPv6, 这会破坏其他类似的连接访问来自应用程序,只能通过IPv4的可用WSDL的URL。 请注意网络连接,特别是Windows 8。