当前位置:编程学习 > JSP >>

配置weblogic的connection pool和Data Source

答案:
os version:windwos2000 serverhostname:mytestdatabase:oracle 9.2.0.1port:1521table: test(a number(2))user:systempassword:oracleweblogic version: 7.0.4domain:mydomainserver:myserverport:7001WL_HOME:d:\bea\weblogic1.配置connection pool打開weblogic管理控制台[http://mytest:7001/console]mydomain->services->jdbc->connection pools新增一connection poolname: OraThinpoolurl: jdbc:oracle:thin:@mytest:1521:technetDriver Classname: oracle.jdbc.driver.OracleDriverproperties:user=systempassword: oracletarget: myservertest table name: dual2.配置Data Source打開weblogic管理控制台[http://mytest:7001/console]mydomain->services->jdbc->Data Source新增一Data Sourcename: OraThinDSJNDI Name: jndi_orathinDSPool Name: OraThinPooltarget: myserver3.測試代易做图Context ctx = null;Hashtable ht = new Hashtable();ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");ht.put(Context.PROVIDER_URL,"t3://mytest:7001");try {ctx = new InitialContext(ht);javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("jndi_orathinDS");java.sql.Connection conn = ds.getConnection();Statement stmt=conn.createStatement();String sql="select a from test";ResultSet rs=stmt.executeQuery(sql);while (rs.next()){int i=rs.getInt(1);System.out.println(i);}}catch(Exception e){e.printStackTrace();}rs.close();stmt.close();conn.close();4.附注數據庫的jdbc驅動位置應該在環境變量classpath中出現,本例使用的驅動為classes12.zip 位於d:\bea\weblogic erver\lib則classpath=d:\bea\weblogic erver\lib\classes12.zip;%CLASSPATH%修改d:\bea\weblogic erver\bin tartWLS.cmd中的classpath後重新啟動weblogic即可

上一个:Eclipse快捷键指南
下一个:25级阶梯,每次走一步或两步,问最多有多少种走法

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,