tomcat数据库连接池
来源:互联网 发布:ubuntu 15.10 下载 编辑:程序博客网 时间:2024/05/01 02:03
Oracle数据源配置:
1,在%CATALINA_HOME%/conf 下的server.xml中配置如下节点(host节点里面)
<!-- Context节点的path属性就是你的WebApp服务名
例如:http://localhost:8080/YouWeb/index.jsp 这个是访问你网站的URL,那么你的path就是: /YouWeb
-->
<Context path="/YouWeb">
<Resource
name="jdbc/oracal"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
maxIdle="2"
maxWait="5000"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@localhost:1521:oraDB"
maxActive="4"/>
</Context>
2,在你的项目工程目录WEB-INf/web.xml中配置如下信息:
<!--注意:res-ref-name节点里的名字要与上面的Resource节点里的name要一致。名字可以任意取,但一定要一致。-->
<resource-ref>
<res-ref-name>jdbc/oracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3,最后,在你和程序中使用如下代码即可取得连接:
InitialContext ctx = new InitialContext();
//这里的java:comp/env是前缀,java语言规范,后面跟的是你Web.xml文件中res-ref-name节点中的名字。
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/oracle");
Connection conn = ds.getConnection();
---------------------------------------------------------------------------
----------------------------------------------------------------------------
SqlServer2000数据源配置:
=================================================
Oracle数据源配置:
1,在%CATALINA_HOME%/conf 下的server.xml中配置如下节点(host节点里面)
<!-- Context节点的path属性就是你的WebApp服务名,与上面同。
例如:http://localhost:8080/YouWeb/index.jsp 这个是访问你网站的URL,那么你的path就是: /YouWeb
-->
<Context path="/YouWeb">
<Resource
name="jdbc/sqlserver"
type="javax.sql.DataSource"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle="2"
maxWait="5000"
username="sa"
password="sa"
url="jdbc:microsoft:sqlserver://localhost;DatabaseName=dbname"
maxActive="4"/>
</Context>
2,在你的项目工程目录WEB-INf/web.xml中配置如下信息:
<!--注意:res-ref-name节点里的名字要与上面的Resource节点里的name要一致。名字可以任意取,但一定要一致。-->
<resource-ref>
<res-ref-name>jdbc/sqlserver</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3,最后,在你和程序中使用如下代码即可取得连接:
InitialContext ctx = new InitialContext();
//这里的java:comp/env是前缀,java语言规范,后面跟的是你Web.xml文件中
res-ref-name节点中的名字。
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/server");
Connection conn = ds.getConnection();
---------------------------------------------------------------------------
----------------------------------------------------------------------------
mysql数据源配置:
==================================================
1,在%CATALINA_HOME%/conf 下的server.xml中配置如下节点(host节点里面)
<!-- Context节点的path属性就是你的WebApp服务名,与上面同。
例如:http://localhost:8080/YouWeb/index.jsp 这个是访问你网站的URL,那么你的path就是: /YouWeb
-->
<Context path="/YouWeb">
<Resource
name="jdbc/mysql"
type="javax.sql.DataSource"
driverClassName="org.gjt.mm.mysql.Driver"
maxIdle="2"
maxWait="5000"
username="root"
password="root"
url="jdbc:mysql://localhost/mysqlDBName"
maxActive="4"/>
</Context>
2,在你的项目工程目录WEB-INf/web.xml中配置如下信息:
<!--注意:res-ref-name节点里的名字要与上面的Resource节点里的name要一致。名字可以任意取,但一定要一致。-->
<resource-ref>
<res-ref-name>jdbc/mysql</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3,最后,在你和程序中使用如下代码即可取得连接:
InitialContext ctx = new InitialContext();
//这里的java:comp/env是前缀,java语言规范,后面跟的是你Web.xml文件中
res-ref-name节点中的名字。
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection conn = ds.getConnection();
---------------------------------------------------------------------------
---------------------------------------------------------------------------
=================================================
- tomcat配置数据库连接池
- tomcat数据库连接池
- 配置tomcat数据库连接池
- tomcat数据库连接池配置
- tomcat配置数据库连接池
- tomcat 数据库连接池配置
- Tomcat 数据库连接池配置
- tomcat数据库连接池配置!
- tomcat-mysql数据库连接池
- tomcat数据库连接池配置
- tomcat-mysql数据库连接池
- TOMCAT数据库连接池相关
- Tomcat数据库连接池
- tomcat数据库连接池配置
- tomcat数据库连接池配置
- tomcat数据库连接池
- Tomcat 配置数据库连接池
- Tomcat数据库连接池配置
- TOMCAT路径问题
- 解锁scott用户及设置密码
- PSA
- Tomcat6.0虚拟目录配置
- VSS 连接报错 :The Sourcesafe Web service cannot be accessed at the specified address
- tomcat数据库连接池
- TemplateMethod パターン
- 导航控件
- struts2 CheckBoxList使用时要注意的问题
- .NET C# gridview 分页 样式
- Tomcat6数据库连接池的配置
- TomCat6.0数据库连接池配置实例(mysql数据库)
- select @@identity as value
- JSP Request方法大全