zoukankan
html css js c++ java
JSP+Tomcat+SQL Server2000连接池的配置
修改Tomcat 5.5\conf目录下的context.xml,加入下列
<
Resource
name
="jdbc/mobile"
type
="javax.sql.DataSource"
password
="neusoft"
driverClassName
="com.microsoft.jdbc.sqlserver.SQLServerDriver"
maxIdle
="2"
maxWait
="5000"
username
="sa"
url
="jdbc:microsoft:sqlserver://localhost:1433;databaseName=OK"
maxActive
="4"
/>
其中,以后只修改mobile为你的工程名,url中为你的数据库连接字符串
下面是读取连接的Java代码
package
beans;
import
javax.naming.
*
;
import
javax.sql.
*
;
import
java.sql.
*
;
public
class
Cone
{
public
Connection init()
{
Connection conn
=
null
;
try
{
Context ctx
=
new
InitialContext();
if
(ctx
==
null
)
throw
new
Exception(
"
Boom - No Context
"
);
DataSource ds
=
(DataSource)ctx.lookup(
"
java:comp/env/jdbc/mobile
"
);
if
(ds
!=
null
)
{
conn
=
ds.getConnection();
}
}
catch
(Exception e)
{
e.printStackTrace();
}
return
conn;
}
}
查看全文
相关阅读:
Cycle Sort
使用finalize/dispose 模式提高GC性能(翻译)
支持在控件标签间包含子控件 WebControl
MongoDB 使用GridFS保存文件
MongoDB学习笔记
跨域名单点登录 part 1 设计蓝图(翻译)
UserControl 用户自定义控件
为什么90%的IT人员都不适合做老大?
什么情况下你会毫不犹豫地辞职?
Supervisor安装、配置、开启启动
原文地址:https://www.cnblogs.com/bearhb/p/438742.html
最新文章
QPS、PV和需要部署机器数量计算公式(转)
Scrum框架及其背后的原则(上)——Scrum 框架的伪代码描述(转)
随笔项目管理的瞎想
推荐文章2011.12.05
IE7 绝对定位zindex问题
基于SQL Server 2008 Service Broker构建企业级消息系统(转)
Cannot open the disk 'XXX' or one of the snapshot disks it depends on. reason: failed to lock the file.
关于NoSQL你必须知道的九件事(转)
Sql 2008查询优化逻辑转换
Web入侵安全检测之表单提交 (转)
热门文章
nginx配置说明
Centos yum
nodejsnodemon
MySQL的root用户设置密码
安装MySQL
git项目
删除匿名用户
GC:.net framework中的自动内存管理part 1 (翻译)
基于Mongodb的file server
GC:.net framework中的自动内存管理part 2 (翻译)
Copyright © 2011-2022 走看看