Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server » WebLogic  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 WebLogic9.2 + MS SQLServer2000连接池
errorpro





发贴: 2
积分: 0
于 2007-10-02 23:30 user profilesend a private message to usersend email to errorprosearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1。系统平台
WIN2003+WebLogic9.2+MS SQLServer2000(已经打上SP4补丁,使用的是SP3驱动)

2。修改C:\bea\weblogic92\server\bin\startWLS.cmd中的CLASSPATH
set CLASSPATH=%JAVA_HOME%\lib\tools.jar;%WL_HOME%\server\lib\weblogic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%WL_HOME%\server\lib\msbase.jar;%WL_HOME%\server\lib\msutil.jar;%WL_HOME%\server\lib\mssqlserver.jar;

3。新建立的域中添加了msbase.jar,mssqlserver.jar,msutil.jar ,wlclient.jar包
C:\bea\user_projects\domains\base_domain\lib

4。在WebLogic9.2中不管使用WebLogic9.2自带的驱动还是选用MS的驱动测试连接都能完成。

5。测试代码如下:
package com.until;

import java.sql.Connection;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnDatabasePool {

  /**
   * @param args
   */
  public static void main(String[] args) {
Properties properties = null;
     DataSource ds=null;
     String user = null;
     String password = null;
    
    
     try {
     properties = new Properties();
     properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
     properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
     if (user != null) {
     properties.put(Context.SECURITY_PRINCIPAL, user);
     properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
     }

     Context ctx = new InitialContext(properties);
     ds = (javax.sql.DataSource) ctx.lookup("SQLServerJNDI");//SQLServerJNDI为WebLogic9.2 中配置的JNDI 名称
     Connection con = ds.getConnection();
if(con!=null){
     System.out.println("数据库连接成***!");
     }
     }catch(Exception e){
     System.out.println("数据库连接失败!");
     System.out.println(e.getMessage());
     }    
    }

  }

6。经编译下面测试程序后给出如下提示:
数据库连接失败!
Unexpected Exception

希望大家能够帮助解决,谢谢!!!!!!!!!!!!!!!!!!




话题树型展开
人气 标题 作者 字数 发贴时间
11180 WebLogic9.2 + MS SQLServer2000连接池 errorpro 1922 2007-10-02 23:30

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923