当前位置:文章首页 >> weblogic容器专区 >> weblogic连接池配置实现
weblogic连接池配置实现
2008-05-13 20:59:33  作者:51j2ee整理  来源:互联网  浏览次数:0  文字大小:【】【】【
  •    使用weblogic自带数据库驱动jDriver,在console里配置连接池。 配置的步骤我就不说了,实现代码如下: private DataSourcePool(String initialContextFactory, String providerUrl, String jndiNam ...
            使用weblogic自带数据库驱动jDriver,在console里配置连接池。

          配置的步骤我就不说了,实现代码如下:

private DataSourcePool(String initialContextFactory, String providerUrl, String jndiName) {

             

        Hashtable ht = new Hashtable();

        ht.put(Context.INITIAL_CONTEXT_FACTORY,initialContextFactory);

        ht.put(Context.PROVIDER_URL,providerUrl);

        try{

               

                ctx = new InitialContext(ht);

                ds = (DataSource)ctx.lookup (jndiName);

                System.out.println("datasource池子创建成功!");

            }

            catch(Exception ex)

            {

                System.err.println("Error in PooledSQL-construct : ");

                ex.printStackTrace(System.err);

            }

       }

这样出现一个很怪异的问题,就是用该驱动获得的连接查询数据库,如果整型的值在0-9之间,都会查出来是0。其它的范围没有问题。包括count()之类函数查询出来的也有这种问题,估计是weblogic自带的驱动和oracle不兼容引起的。


 


 


3、  使用oracle自带的数据库驱动,在console下配置连接池。

除了配置时选择的驱动不一样以外,其它一切都不变,这种配置方法目前为止还没有发现问题。

综上所述:在weblogic下配置oracle数据库连接池,目前找到的最和需求的方法就是3、使用oracle自带的数据库驱动,在console下配置连接池。

 

 

Context ctx = null;

Hashtable ht = new Hashtable();

ht.put(Context.INITIAL_CONTEXT_FACTORY,

"weblogic.jndi.WLInitialContextFactory");

ht.put(Context.PROVIDER_URL,

"t3://localhost:7001");

try {

ctx = new InitialContext(ht);

// Use the context in your program

}

catch (NamingException e) {

// a failure occurred

}

finally {

try {ctx.close();}

catch (Exception e) {

// a failure occurred

}

}


dbConnection = datasource.getConnection();


 

 

第一步建立Weblogic Server的project:

(1)安装破解Weblogic 8.3.1后(www.9iv.com),运行Configuration Wizard;

(2)选择Create a new Weblogic configuraion;

(3)Select a Configuration Template中选择Basic Weblogic Server Domain;

(4)Chose Express or Custom Configuration中我选择的是Express(如果对配置很熟悉还是选择Custom比较好些);

(5)在Configure Administrative Username and Password中设置用户名和密码;

(6)在Configure Server Start Mode and Java SDK中我选择了Development Mode,在JDK中选择了BEA默认安装的Sun JDK 1.4.2_04;

(7)在下一步部署中输入需要的Congfiguration Name就可以Create了。

第二步在MyEclipse配置Weblogic:

(1)选择菜单Window->Preferences->MyEclipse->Application Servers->Weblogic 8,配置项目如下:

BEA home directory: 选择Bea的安装目录

Weblogic installation directory:现在BEA下面的weblogic81目录

Admin username:输入上面在配置过程中设的用户名

Admin password:输入刚才设的密码

Execution domain root:选择BEA下user_projects\domains目录下上面第一步创建的目录

Execution domain name:输入上面那个目录的名称

Execution server name:输入上一步的那个Congfiguration Name

Hostname:PortNumber:输入IP地址和监听的端口

Security policy file:输入BEA安装目录下的\weblogic81\server\lib\weblogic.policy

(2)在Weblogic 8下面配置JDK,在WLS JDK name那里选择新建,弹出的对话框中选择BEA下面的JDK安装路径,输入一个名字确定就可以;在Optional Java VM arguments对话框里面输入-ms64m -mx64m -Djava.library.path="D:/BEA/weblogic81/server/bin" -Dweblogic.management.discover=false -Dweblogic.ProductionModeEnabled=false

0

顶一下

0

踩一下
友情链接 | 诚聘英才 | 关于我们 | 版权声明 | 联系我们 | 网站公告 | 广告服务

  • j2ee行业网站
  • 在线咨询:            
  •     京ICP备6212353号    Powered by j2ee