国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

WebLogic7中的JDBC Pool的配置

2024-07-21 02:15:03
字體:
來源:轉載
供稿:網友
  • 本文來源于網頁設計愛好者web開發社區http://www.html.org.cn收集整理,歡迎訪問。
  •   一、 采用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:[email protected]: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());
      
      };
      
      %>
    發表評論 共有條評論
    用戶名: 密碼:
    驗證碼: 匿名發表
    主站蜘蛛池模板: 南木林县| 徐水县| 大冶市| 申扎县| 江永县| 德州市| 老河口市| 南城县| 天水市| 蒲江县| 黔西| 宁蒗| 安塞县| 铁岭县| 临颍县| 萨嘎县| 丹寨县| 广西| 武功县| 潮安县| 佛学| 赤壁市| 双峰县| 榆社县| 姚安县| 广德县| 板桥市| 安新县| 无锡市| 凤凰县| 潞西市| 沾益县| 普兰县| 邻水| 固阳县| 河曲县| 九龙县| 清远市| 色达县| 清水县| 安西县|