tomcat6.0数据库连接池配置实例(informix)
求大神支持下informix,如何配置tomcat数据库连接池,详细步骤 Tomcat Informix 数据库连接池 实例 --------------------编程问答-------------------- 我做的尝试:1,在E:\mywork\apache-tomcat-6.0.32\lib下引入ifxjdbc.jar2,配置E:\mywork\apache-tomcat-6.0.32\conf下的context.xml,配置如下
<Resource
name="jdbc/informix"
type="javax.sql.DataSource"
driverClassName="com.informix.jdbc.IfxDriver"
maxIdle="2"
maxWait="5000"
username="cbsl"
password="qqww"
url="jdbc:informix-sqli://localhost:9021/hn4300car3gdb:informixserver=hn_4300_cb_ids;NEWLOCALE=zh_CN,zh_CN;NEWCODESET=gb18030,8859-1,819;IFX_USE_STRENC=true"
maxActive="4"/>
3,在web.xml中配置如下<resource-ref>
<description>Informix DB Connection Pool</description>
<res-ref-name>jdbc/informix</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
4,test测试数据
public static void main(String[] args) {
DataSource ds = null;
try{
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (DataSource) envCtx.lookup("jdbc/informix");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String strSql = " select psncode,psnname from bd_psndoc";
ResultSet rs = stmt.executeQuery(strSql);
ArrayList<Monopolyer> ms= new ArrayList<Monopolyer>();
while(rs.next()){
Monopolyer m=new Monopolyer();
m.setPsncode(rs.getString(1));
m.setPsnname(rs.getString(2));
System.out.println(m.getPsncode());
ms.add(m);
}
}
catch(Exception ex){
ex.printStackTrace();
}
}
5,报错----javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
补充:Java , Web 开发