分享
 
 
 

WebLogic7中的JDBCPool的配置

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

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

};

%

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有