没有合适的资源?快使用搜索试试~ 我知道了~
java其中的一个连接数据库办法的过程 有三个步骤
资源推荐
资源详情
资源评论
xml配置
<resource-ref>
<res-ref-name>jdbc/print</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
连接代码
public static Connection getConn(){
Connection conn = null;
try{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/print");
conn= ds.getConnection();
}catch(Exception e){
e.printStackTrace();
}
return conn;
}
Tomat的配置
tomcat\apache-tomcat-5.5.17\conf\context.xml 下添加
<resource-ref>
<res-ref-name>jdbc/print</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
连接代码
public static Connection getConn(){
Connection conn = null;
try{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/print");
conn= ds.getConnection();
}catch(Exception e){
e.printStackTrace();
}
return conn;
}
Tomat的配置
tomcat\apache-tomcat-5.5.17\conf\context.xml 下添加
资源评论
lzzz999
- 粉丝: 7
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功