Resin 服务器配置Mysql数据库连接
来源:互联网 发布:混凝土销售软件 编辑:程序博客网 时间:2024/05/17 03:46
新建一个resin.conf文件,在里面添加如下xml配置信息:
<resource-ref>
<res-ref-name>jdbc/comstep</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<init-param driver-name="org.gjt.mm.mysql.Driver"/>
<init-param url="jdbc:mysql://localhost/comstep"/>
<init-param user="root"/>
<init-param password="comstep"/>
<init-param characterEncoding="gbk"/>
<init-param useUnicode="true"/>
<init-param serverVersion="Sql7"/>
<init-param max-connections="5"/>
<init-param max-idle-time="30"/>
</resource-ref>
<res-ref-name>jdbc/comstep</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<init-param driver-name="org.gjt.mm.mysql.Driver"/>
<init-param url="jdbc:mysql://localhost/comstep"/>
<init-param user="root"/>
<init-param password="comstep"/>
<init-param characterEncoding="gbk"/>
<init-param useUnicode="true"/>
<init-param serverVersion="Sql7"/>
<init-param max-connections="5"/>
<init-param max-idle-time="30"/>
</resource-ref>
在初始化的servlet中,使用Jndi 对数据库资源绑定到对象:
/*
* 初始化需要的 jndi 节点。
*/
try
{
Context env = (Context) new InitialContext().lookup("java:comp/env");
* 初始化需要的 jndi 节点。
*/
try
{
Context env = (Context) new InitialContext().lookup("java:comp/env");
env.createSubcontext("comstep");
}
catch (NamingException e)
{
System.out.println("NamingException");
return;
}
}
catch (NamingException e)
{
System.out.println("NamingException");
return;
}
/*
* 初始化数据库接入点。
*/
try
{
String resRef = getInitParameter("resource-ref");
* 初始化数据库接入点。
*/
try
{
String resRef = getInitParameter("resource-ref");
Context env = (Context) new InitialContext().lookup("java:comp/env");
env.bind("comstep/DataConnection", dataConnection);
System.out.println("DataConnection binded");
}
catch (Exception e)
{
System.out.println("DataConnection bind error");
}
catch (Exception e)
{
System.out.println("DataConnection bind error");
return;
}
}
在Jsp中使用:
Context env = (Context) new InitialContext().lookup("java:comp/env");
dataConnection= (DataConnection)env.lookup("comstep/DataConnection");
[注]:DataConnection是自己写的一个类,这里没有列出。主要说一下jndi对数据库的绑定。
- Resin 服务器配置Mysql数据库连接
- Resin配置数据库连接池
- resin数据库连接池配置
- [resin]Resin服务器配置说明
- Resin服务器配置指南
- resin服务器配置
- resin服务器配置
- Resin服务器配置指南
- Resin服务器配置指南
- Resin服务器配置指南
- Resin服务器配置说明
- resin服务器配置详解
- Resin服务器配置指南
- eclipse 配置resin服务器
- resin服务器配置
- Mac服务器搭建以及MySQL数据库连接:Apache(Tomcat,Resin),PHP,MYSQL,Navicat
- Eclipse配合Resin开发web,附加mysql数据库连接池配置设置整合与测试
- Eclipse配合Resin开发web,附加mysql数据库连接池配置设置整合与测试
- 《细节决定成败》语录
- 三峡大坝为混凝土重力坝 瞬间垮塌只会威胁宜昌
- 关于进行Asp.net窗体验证的过程说明
- 令人头疼的中文问题
- showModalDialog和showModelessDialog使用心得(附window.showModalDialog使用手册)
- Resin 服务器配置Mysql数据库连接
- 很闷的几个星期
- 服务组件中的用户名和口令
- 感谢郭拉!
- jsp+tomcat+mysql&sevlet&javabean配置全过程
- 生动的ajax图片显示效果,LightBox
- .net平台的ajax试炼,校验用户名
- 快捷菜单
- .net平台ajax解决方案