数据源

来源:互联网 发布:windows java进程监控 编辑:程序博客网 时间:2024/06/05 02:30
修改context.xml文件
<Context reloadable=“true”><WatchedResource>WEB-INF/web.xml</WatchedResource><Resource name=“jdbc/oracleds” auth=“Container”type=“javax.sql.DataSource”maxActive=“100” maxIdle=“30” maxWait=“10000”username=“scott” password=“tiger”driverClassName=“oracle.jdbc.OracleDriver”url=“jdbc:oracle:thin:@192.168.1.20:1521:ora9”/></Context>



使用数据源:
Context context = new InitialContext();
DataSource ds = (DataSource)context.lookup("java:/comp/env/jdbc/oracleds");
Connection conn = ds.getConnection();

...
原创粉丝点击