0
我试图使用JNDI查找获取连接池,但有以下错误:java.sql.SQLException中:不能“的连接网址”创建一流的“JDBC驱动程序无效”JNDI查找连接池
我上下文XML放置在幅/ WEB-INF文件夹邻近的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" crossContext="true" reloadable="true" path="patient/account">
<Resource
name="jdbc/pharmacy"
author="Container"
type="javax.sql.DataSource"
maxActive="32"
maxIdle="8"
maxWait="10000"
username="root"
password="23810198vas"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/pharmacy" />
</Context>
Context envCtx = new InitialContext();
DataSource ds = (DataSource)envCtx.lookup("java:comp/env/jdbc/pharmacy");
Connection connection = ds.getConnection();
对于Tomcat,context.xml应该位于** META-INF **之下,并且** META-INF **文件夹应该与** WEB-INF **文件夹位于同一级别。 – Roshith
谢谢!现在正在工作 –