Exception:
从连接池中获取数据库连接发生异常 : Cannot create PoolableConnectionFactory (Illegal connection port value '3306:DB)
Solution:
1.在Tomcat中server.xml的<GlobalNamingResources> 节点里面添加如下代码:
<Resource name="jdbc/mbss" auth="Container" type="javax.sql.DataSource"
username="root"
password="root"
driverClassName="com.mysql.jdbc.Driver"
maxIdle="10"
maxWait="10000"
maxActive="100"
url="jdbc:mysql://localhost:3306/DB" />
2.在Tomcat中context.xml的</context>前添加如下代码:
<ResourceLink name="jdbc/DB" global="jdbc/DB" type="javax.sql.DataSourcer"/>
3.在所建项目中web.xml的</web-app>前添加如下代码:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/mbss</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
4.在获得数据库连接池中这样写,如:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/DB");
con = ds.getConnection();
相关推荐
在SQL Server 2005中,"Cannot create PoolableConnectionFactory (用户 'sa' 登录失败。该用户与可信 SQL Server 连接无)" 错误通常表明在尝试使用SQL Server的身份验证方式登录时遇到了问题。这篇博客文章可能详细...
- `maxWait`是等待连接的最大时间,如果超过这个时间仍无法获取连接,会抛出`SQLException`,这里的值为10000毫秒(10秒)。 - `username`和`password`是数据库的登录凭据。 - `driverClassName`指定了数据库驱动...
NULL 博文链接:https://lectery.iteye.com/blog/485357
在执行JDBC Request之后,我们可能会出现一个报错:java.sql.SQLException: Cannot create PoolableConnectionFactory (The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more...
确认SQL Server 2000可以远程连接,除了开放1433端口外,还要升级数据库到SP3或SP4,否则连接会发出SQLNestedException:Cannot create PoolableConnectionFactory ([Microsoft][SQLServer 2000 Driver for JDBC]...
该问题的错误信息为:Cannot create PoolableConnectionFactory (The server time zone value '???��������??��??' is unrecognized or represents more than one time zone. You must configure either ...