请教TOMCAT5.0.11连接池配置问题,??

03-11-06 xhaopuj2003
请看我错误信息:

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

xhaopuj2003
2003-11-06 11:22
我的server.xml :

<Context path="/hibstu" docBase="hibstu" debug="5" reloadable="true" crossContext="true">

<Resource name="jdbc/hibernate" auth="Container" type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/hibernate">

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<parameter>

<name>driverClassName</name>

<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>

</parameter>

<parameter>

<name>url</name>

<value>jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=hibernateDB</value>

</parameter>

<parameter>

<name>username</name>

<value>program</value>

</parameter>

<parameter>

<name>password</name>

<value>seavision</value>

</parameter>

<parameter>

<name>maxActive</name>

<value>20</value>

</parameter>

<parameter>

<name>maxIdle</name>

<value>10</value>

</parameter>

<parameter>

<name>maxWait</name>

<value>-1</value>

</parameter>

</ResourceParams>

</Context>

<!-- end tuanwei.liu new add 2003-10-29 20:05 -->

xhaopuj2003
2003-11-06 11:23
我的:测试代码:

<%

DataSource ds = null;

try{

Context initCtx = new InitialContext();

Context envCtx = (Context) initCtx.lookup("java:comp/env");

ds = (DataSource)envCtx.lookup("jdbc/hibernate");

if(ds!=null)

{

out.println("Connection is OK!");

out.println("<br>");

out.println("Connection get 1!");

Connection conn = ds.getConnection();

out.println("Connection get 1!");

if(conn!=null){

Statement stmt=conn.createStatement();

//stmt.execute("create table ttt(tt int)");

ResultSet rst=stmt.executeQuery("select * from person");

while(rst.next()) {

out.println(rst.getString("id"));

out.println("<br>");

}

}else{

out.println("connetion Fail!");

}

}else

out.println("Fail!");

}catch(Exception ne){ out.println(ne);}

%>

xhaopuj2003
2003-11-06 11:23
<%

DataSource ds = null;

try{

Context initCtx = new InitialContext();

Context envCtx = (Context) initCtx.lookup("java:comp/env");

ds = (DataSource)envCtx.lookup("jdbc/hibernate");

if(ds!=null)

{

out.println("Connection is OK!");

out.println("<br>");

out.println("Connection get 1!");

Connection conn = ds.getConnection();

out.println("Connection get 1!");

if(conn!=null){

Statement stmt=conn.createStatement();

//stmt.execute("create table ttt(tt int)");

ResultSet rst=stmt.executeQuery("select * from person");

while(rst.next()) {

out.println(rst.getString("id"));

out.println("<br>");

}

}else{

out.println("connetion Fail!");

}

}else

out.println("Fail!");

}catch(Exception ne){ out.println(ne);}

%>

猜你喜欢