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

首頁 > 學院 > 開發設計 > 正文

WebLogic7中的JDBC Pool的配置

2019-11-18 12:37:33
字體:
來源:轉載
供稿:網友

  一、 采用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());
  
  };
  
  %>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阳原县| 禄丰县| 丽江市| 永昌县| 三都| 太保市| 平乐县| 松江区| 沐川县| 崇信县| 双鸭山市| 大悟县| 新龙县| 丽江市| 民权县| 浙江省| 山西省| 丰原市| 安化县| 高唐县| 河东区| 株洲县| 西乌珠穆沁旗| 溧阳市| 阿瓦提县| 泰安市| 湘乡市| 始兴县| 鄄城县| 府谷县| 揭西县| 威远县| 三穗县| 涞水县| 咸阳市| 河东区| 闸北区| 仪征市| 阳城县| 古交市| 永泰县|