当前位置: 技术问答>java相关
老问题:在Tomcat server.xml中配置连接池(但错误不一样)
来源: 互联网 发布时间:2017-04-02
本文导语: 我是这样写的server.xml: driverClassName com.microsoft.jdbc.sqlserver.SQLServerDriver driverName jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind; usersa passwordgo web.xml: .... jdbc/DB javax.sql.DataSource Contai...
我是这样写的server.xml:
driverClassName
com.microsoft.jdbc.sqlserver.SQLServerDriver
driverName
jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind;
usersa
passwordgo
web.xml:
....
jdbc/DB
javax.sql.DataSource
Container
JSP:
DataSource ds = null;
Connection con=null;
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
ds = (DataSource)envCtx.lookup("jdbc/DB");
con = ds.getConnection();//此行出错,error:
Cannot create JDBC driver of class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' for connect URL 'null'
期待你的帮助,现谢了!
driverClassName
com.microsoft.jdbc.sqlserver.SQLServerDriver
driverName
jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind;
usersa
passwordgo
web.xml:
....
jdbc/DB
javax.sql.DataSource
Container
JSP:
DataSource ds = null;
Connection con=null;
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
ds = (DataSource)envCtx.lookup("jdbc/DB");
con = ds.getConnection();//此行出错,error:
Cannot create JDBC driver of class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' for connect URL 'null'
期待你的帮助,现谢了!
|
user改成
username
url改成
driverName
username
url改成
driverName
|
jdbc:microsoft:sqlserver://101.4.0.212:1433;databasename=comminfo
10.0.0.212//为你机器的ip而不是127.0.0.1
DatabaseName=Northwind;
->
DatabaseName=Northwind//分号去掉
10.0.0.212//为你机器的ip而不是127.0.0.1
DatabaseName=Northwind;
->
DatabaseName=Northwind//分号去掉