reloadable="true" source="org.eclipse.jst.j2ee.server:TestDevon">
maxWait
5000
maxActive
20
factory
org.apache.commons.dbcp.BasicDataSourceFactory
url
jdbc:mysql://localhost:3306/testdevon?autoReconnect=true
driverClassName
com.mysql.jdbc.Driver
maxIdle
10
username
root
password
lgcnschina
2. 确认MySql驱动是否存放在tomcat下的common\lib文件夹中
3. 测试数据源的配置是否成功
(1) 在web.xml中添加如下代码
DataSource
jdbc/mysql
javax.sql.DataSource
Container
(2) 测试数据源
test jndiContext initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env"); DataSource ds = (DataSource) ctx.lookup("jdbc/mysql");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from user_info");
while (rs.next()) {
%>
}
rs.close();
stmt.close();
conn.close();
%>
分享到:
2010-09-17 17:02
浏览 500
分类:非技术
评论