• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    WebLogic7中的JDBC Pool的配置

    發布: 2007-6-22 07:38 | 作者:   | 來源:   | 查看: 16次 | 進入軟件測試論壇討論

    領測軟件測試網

       
      一、 采用Microsoft的JDBC Driver
      
      1 到www.microsoft.com上下載“Microsoft SQL Server 2000 Driver for JDBC”并安裝
      
      2 安裝后,在安裝的目錄中有三個jar文件包
      msbase.jar
      msutil.jar

      mssqlserver.jar
      
      建議將其拷貝出來放置到%WL_HOME%\server\lib目錄中(其實隨意,但附后的classpath中要指明)
      
      3 將3個jar包加入到classpath中,改startWLS.cmd,“set CLASSPATH=”后插入%WL_HOME%\server\lib\msbase.jar;%WL_HOME%\server\lib\msutil.jar;%WL_HOME%\server\lib\mssqlserver.jar;
      **
      注意:用weblogic7最好在創建domain前更改上面的設置。否則有可能出現不可預知的問題。
      
      4 確認MSSQLServer的端口號(這點比較重要)
      And to find the port number where your instance is running, run the
      server.network utility and select the server instance and select the
      TCP/IP. When you click the properties button, it will show the port.
      
      5 啟動WebLogic
      
      6 打開IE,在地址欄中輸入:http://localhost:7001/console
      
      7 輸入用戶名和密碼
      
      8 在左邊的目錄樹中選中Services->JDBC->Connection Pools,單擊右側的Configure a new JDBC Connection Pool.,輸入以下信息:
      
      Configuration->General頁:
      Name = MSSQLServerConnectionPool
      URL = jdbc:microsoft:sqlserver://newsserv:1433;DatabaseName=wjw_test (注意端口號填第5步中看到的port)
      Driver classname =com.microsoft.jdbc.sqlserver.SQLServerDriver
      Properties :user=sa
      
      password = sa的密碼
      
      單擊Create建立連接池。
      
      9 Connection屬性設置
      
      Configuration->Connections頁:
      
      將Initial Capacity由1置為1 (視需求
      
      將Maximum Capacity由1置為10(視需求)
      
      10 Targets->Server頁:
      
      將myserver(服務器名稱)移至右側的列表中,但擊單擊Apply
      
      11 配置數據源
      
     。 在左邊的目錄樹中選中Services->JDBC->Data Sources(或者TXData Sources),單擊右側的Configure a new JDBC Connection Pool.,輸入以下信息:
      
      Configuration->General頁:
      Name = SQLServer Tx Data Source
      JNDI Name = SQLServer
      Pool Name = MSSQLServerConnectionPool
      
      選中Row Prefetch Enabled
      
      單擊Create建立數據源。
      
      12 Targets->Server頁:
      
      將myserver(服務器名稱)移至右側的列表中,但擊單擊Apply,配置完畢。
      
      13 reboot server
      
      二、采用WebLogic的JDBC Driver for SQL Server
      
      1確認MSSQLServer的端口號(這點比較重要)
      And to find the port number where your instance is running, run the
      server network utility and select the server instance and select the
      TCP/IP. When you click the properties button, it will show the port.
      
      2 啟動WebLogic
      
      3 打開IE,在地址欄中輸入:http://localhost:7001/console
      
      4 輸入用戶名和密碼
      
      5 在左邊的目錄樹中選中Services->JDBC->Connection Pools,單擊右側的Configure a new JDBC Connection Pool.,輸入以下信息:
      
      Configuration->General頁:
      Name = WLSQLServerConnectionPool
      URL = jdbc:weblogic:mssqlserver4:northwind@localhost:2040
      Driver classname = weblogic.jdbc.mssqlserver4.Driver
      Properties :user=sa
      password = sa的密碼
      
      單擊Create建立連接池。
      
      6 Connection屬性設置
      Configuration->Connections頁:
      將Initial Capacity由1置為10 (視需求)
      將Maximum Capacity由1置為10(視需求)
      
      7 Targets->Server頁:
      
      將myserver(服務器名稱)移至右側的列表中,但擊單擊Apply
      
      8 配置數據源
      
     。 在左邊的目錄樹中選中Services->JDBC->Data Sources(或者TXData Sources),單擊右側的Configure a new JDBC Connection Pool.,輸入以下信息:
      Configuration->General頁:
      Name = SQLServer Tx Data Source
      JNDI Name = SQLServer
      Pool Name = WLSQLServerConnectionPool
      選中Emulate Two-Phase Commit for non-XA Driver和Row Prefetch Enabled
      
      單擊Create建立數據源。
      
      9 Targets->Server頁:
      
      將myserver(服務器名稱)移至右側的列表中,但擊單擊Apply,配置完畢。
      
      10 reboot server
      
      Re:WebLogic中SQL Server2000的JDBC Pool配置
      
      上面的配置文檔很不錯,不過個人建議,在采用 ms sql server數據庫的系統,盡量不要使用weblogic jDriver或ms mssql driver。原因如下:
      
     。1)在以后的版本中,weblogic 將不再對jDriver of mssql server進行支持
      
     。1)ms mssql driver對于Image和text類型(也就是blob和clob類型)的數據查詢,支持不好。
      
      所以,盡量采用第三方的ms sql server driver。只是第三方driver多有使用時間限制。
       
      三、WebLogic中的Oracle的JDBC Driver 的配置
      
      To setup a Connection Pool
      
      0. To update the Oracle Thin Driver bundled with WebLogic Server
      set CLASSPATH=%ORACLE_HOME%\jdbc\lib\classes12.zip;%WL_HOME%\lib\weblogic.jar;%CLASSPATH% (Windows)
      
      1. go to Services/JDBC/Connection Pools page of the weblogic console.
      
      2. Click Configure a new JDBC Connection Pool
      
      3. Fill in the information as following (suppose you are using the oracle jdbc thin driver)
      
      Name: testPool
      URL: jdbcracle:thin:@150.0.5.130:1521:ORACLE
      Driver: oracle.jdbc.driver.OracleDriver
      Properties:user=user1
      password=pass1
      
      4. Click the create button
      
      5. Config the connection property by using the connection tab.
      
      6. Click to the targets tab, select the server that will use this connection pool
      
      7. Create a datasource that use the connection pool
      Name: myDataSource
      JNDI Name: myDataSource
      Pool Name: testPool
      
      8. On targets tab, configure the server to use this datasource
      
      四、連接數據庫代碼
      
      Based on the above configuration, you can get a connection by using
      
      Context ctx = null;
      Hashtable ht = new Hashtable();
      ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      ht.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");//127.0.0.1:7001是Weblogic的地址已經端口
      try {
      ctx = new InitialContext(ht);
      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myDataSource");
      java.sql.Connection conn = ds.getConnection();
      }
      ...
      
      To use direct connection
      
      //Instantiate the driver:
      driver = (Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
      //Make the connection:
      con = driver.connect("jdbcracle:thin:@150.0.5.130:1521:ORACLE", user1, pass1);
      
      使用jsp代碼調用數據 下面是測試JDBC jsp1.jsp文件的內容:
      
      <%@ page contentType="text/html; charset=GBK" %>
      
      <!--測試數據源-->
      
      <%@ page import="javax.naming.Context" %>
      
      <%@ page import="javax.sql.DataSource"%>
      
      <%@ page import="javax.naming.InitialContext"%>
      
      <%@ page import="java.sql.*"%>
      
      <%
      
      DataSource ds = null;
      
      try{
      
      Context ctx = null;
      
      Hashtable ht = new Hashtable();
      
      ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      
      ht.put(Context.PROVIDER_URL, "t3://pkucs-wjw:7001");
      
      try {
      
      ctx = new InitialContext(ht);
      
      ds = (javax.sql.DataSource) ctx.lookup ("jdbc/mssql");
      
      //從Context中lookup數據源。
      
      if(ds!=null)
      
      {
      
      out.println("已經獲得DataSource!");
      
      out.println("<br>");
      
      Connection conn = ds.getConnection();
      
      Statement stmt=conn.createStatement();
      
      ResultSet rst=stmt.executeQuery("select * from accounts");
      
      out.println("以下是從數據庫中讀取出來的數據");
      
      while(rst.next())
      
      {
      
      out.println("bookName:"+rst.getString("id"));
      
      out.println("<br>");
      
      }
      
      }
      
      else
      
      out.println("連接失敗!");
      
      }
      
      catch(Exception ne) {
      
      out.println(ne);
      
      }
      
      }
      
      catch(Exception ex){
      
      System.out.println(ex.getMessage());
      
      };
      
      %>

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>