Weblogic :JDBC-Conncetion pool -> config new ... ->
Name: samplePool//你的名字 
   URL:   jdbc:weblogic:mssqlserver4:127.0.0.1:1433
   Driver Classname:   weblogic.jdbc.mssqlserver4.Driver
   Properties  ://格式是:(key=value) 
                db=你所要连接的数据库名字
                user=sa //system admin得名字(一般默认sa)
                password= //sa的密码
//   ACLName:   不用填写
//   Password:   不用填写
//  Open String Password: 不用填写                        apply  -> target -> chosen (myserver) -> apply
Tx Data Source -> config new..... ->
        Name:  名字,随便起
   JNDI Name:  你的jndi名字
   Pool Name:  上面配置的pool的名字,必须[保证和上面一样!!!同上,apply -> target -> chosen -> apply !!
ok.complete!!!

解决方案 »

  1.   

    请问大哥如何测试呢?
    用下面代码可以吗?
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    public class testD {  public static void main(String[] args) {
        DataSource ds=null;
        Context ctx=null;
        Connection myConn=null;
        try{
          ctx=getInitialContext();
           System.out.println(ctx.toString());     ds=(javax.sql.DataSource)ctx.lookup("dataSource");    }
        catch(Exception e){
          System.out.println ( "Init error"+ e);
        }
      }
      private static Context getInitialContext() throws Exception{
        String url="t3://127.0.0.1:7001";
        String user="system";
        String password="security";
        Properties properties=null;
        try{
          properties=new Properties();
              properties.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
              properties.put(Context.PROVIDER_URL,url);
              if (user!=null){
                properties.put(Context.SECURITY_PRINCIPAL,user);
                properties.put(Context.SECURITY_CREDENTIALS,password==null ? "":password);          }
                  return new InitialContext(properties);    }
        catch (Exception e){
          throw e;
        }
      }
    }