Configuration of the JDBC pool in WebLogic7

Source: Internet
Author: User
Tags connect sql server driver mssql mssql server mssqlserver sql stmt time limit
Web first, using the Microsoft JDBC Driver
  
1 to www.microsoft.com download "Microsoft SQL Server Driver for JDBC" and install
  
2 after installation, there are three jar packages in the installed directory
Msbase.jar
Msutil.jar
Mssqlserver.jar
  
It is recommended that the copy be placed in the%wl_home%\server\lib directory (in fact, optional, but attached to the classpath to indicate)
  
3 Add 3 jar packs to CLASSPATH, Startwls.cmd, "set classpath=" and insert%wl_home%\server\lib\msbase.jar;%wl_home%\server\lib\ Msutil.jar;%wl_home%\server\lib\mssqlserver.jar;
**
Note: It is best to use Weblogic7 to change the above settings before creating domain. Otherwise, unpredictable problems may occur.
  
4 Confirm MSSQLServer Port number (this is more important)
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'll show the port.
  
5 Start WebLogic
  
6 open IE, enter in the Address bar: Http://localhost:7001/console
  
7 Enter user name and password
  
8 in the Left directory tree, select Services->jdbc->connection Pools, click Configure a new JDBC Connection Pool on the right., enter the following information:
  
Configuration->general page:
Name = Mssqlserverconnectionpool
URL = jdbc:microsoft:sqlserver://newsserv:1433;databasename=wjw_test (note port number in the 5th step to see the port)
Driver ClassName =com.microsoft.jdbc.sqlserver.sqlserverdriver
Properties:user=sa
  
Password = password for SA
  
Click Create to establish a connection pool.
  
9 Connection Property settings
  
Configuration->connections page:
  
Initial capacity from 1 to 1 (depending on demand)
  
Maximum capacity from 1 to 10 (depending on demand)
  
Targets->server page:
  
Move the MyServer (server name) to the list on the right, but click Apply
  
11 Configuration Data Source
  
. In the Left directory tree, select Services->jdbc->data Sources (or TxData Sources) and click Configure a new JDBC Connection Pool on the right., enter the following information:
  
Configuration->general page:
Name = SQL Server Tx Data Source
JNDI Name = SQL Server
Pool Name = Mssqlserverconnectionpool
  
Select Row Prefetch Enabled
  
Click Create to establish a data source.
  
Targets->server page:
  
Move the MyServer (server name) to the list on the right, but click Apply to complete the configuration.
  
Reboot server
  
   ii. jdbc Driver for SQL Server with WebLogic
  
1 Confirm MSSQLServer Port number (this is more important)
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'll show the port.
  
2 Start WebLogic
  
3 Open IE, enter in the Address bar: Http://localhost:7001/console
  
4 Enter user name and password
  
5 in the Left directory tree, select Services->jdbc->connection Pools, click Configure a new JDBC Connection Pool on the right., enter the following information:
  
Configuration->general page:
Name = Wlsqlserverconnectionpool
URL = jdbc:weblogic:mssqlserver4:northwind@localhost:2040
Driver classname = Weblogic.jdbc.mssqlserver4.Driver
Properties:user=sa
Password = password for SA
  
Click Create to establish a connection pool.
  
6 Connection Property settings
Configuration->connections page:
Initial capacity from 1 to 10 (depending on demand)
Maximum capacity from 1 to 10 (depending on demand)
  
7 Targets->server page:
  
Move the MyServer (server name) to the list on the right, but click Apply
  
8 Configuration Data Source
  
. In the Left directory tree, select Services->jdbc->data Sources (or TxData Sources) and click Configure a new JDBC Connection Pool on the right., enter the following information:
Configuration->general page:
Name = SQL Server Tx Data Source
JNDI Name = SQL Server
Pool Name = Wlsqlserverconnectionpool
Select emulate two-phase Commit for Non-xa driver and row Prefetch Enabled
  
Click Create to establish a data source.
  
9 Targets->server page:
  
Move the MyServer (server name) to the list on the right, but click Apply to complete the configuration.
  
Ten reboot Server
  
JDBC pool configuration for SQL Server2000 in Re:weblogic
  
The configuration document above is good, but it is recommended that you do not use the WebLogic Jdriver or Ms MSSQL driver in a system that uses the MS SQL Server database. The reasons are as follows:
  
(1) In future releases, WebLogic will no longer support jdriver of MSSQL server
  
(1) Ms MSSQL driver has poor support for data queries for image and text types (that is, blobs and CLOB types).
  
So, try to adopt the third party's MS SQL Server driver. Only third party driver have more use time limit.
   
   Oracle JDBC Driver configuration in WebLogic
  
To setup a Connection Pool
  
0. To update, 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 and select the server that'll 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
  
Four, connect the database code
  
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 is WebLogic address already port
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);
  
Calling data using JSP code The following is the contents of the test JDBC jsp1.jsp file:
  
<%@ page contenttype= "text/html; CHARSET=GBK "%>
  
<!--test data source-->
  
<%@ 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");
  
Lookup the data source from the context.
  
if (ds!=null)
  
{
  
Out.println ("Already obtained datasource!");
  
Out.println ("<br>");
  
Connection conn = Ds.getconnection ();
  
Statement stmt=conn.createstatement ();
  
ResultSet rst=stmt.executequery ("SELECT * from Accounts");
  
OUT.PRINTLN ("The data read from the database Below");
  
while (Rst.next ())
  
{
  
Out.println ("BookName:" +rst.getstring ("id"));
  
Out.println ("<br>");
  
}
  
}
  
Else
  
Out.println ("Connection failed!");
  
}
  
catch (Exception ne) {
  
Out.println (NE);
  
}
  
}
  
catch (Exception ex) {
  
System.out.println (Ex.getmessage ());
  
};
  
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.