分享
 
 
 

How do you configure jConnect JDBC Connection Pooling

王朝java/jsp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

Problem Description:

How do you configure jConnect JDBC Connection Pooling

with Apache Tomcat 4.1.x?

Tip or Workaround:

(Observations performed with jConnect-5_2

and Tomcat 4.1.18)

In line, below, are the text of what should be

saved as 3 files:

web.xml

sybase.jsp

server.xml.SybaseDelta

Please proceed as follows:

1) Create the following folders:

1.1) C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase

1.2) C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase\jsp

1.3) C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase\WEB-INF

1.4) C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase\WEB-INF\jsp

2) Move the file "web.xml" to folder

C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase\WEB-INF

3) Move the file "sybase.jsp" to folder

C:\Program Files\Apache Group\Tomcat 4.1\webapps\sybase\jsp

4) Copy the contents of file "server.xml.SybaseDelta" into your

existing "C:\Program Files\Apache Group\Tomcat 4.1\conf\server.xml"

file.

Insert the new content as an additional context within the

"Tomcat-Standalone" service specification. Insert this after

the last "</context>" entry, but before the "</host>" terminator

in the "Tomcat-Standalone" service grouping.

Replace the following strings with values appropriate

to your installation:

database_hostname

your_dbname

your_userid

your_password

If your dataserver is not "listening" on port 5000,

make the corresponding change for the port, too, in the

connection url.

5) Copy your jConnect\classes\jconn2.jar file into directory

C:\Program Files\Apache Group\Tomcat 4.1\common\lib

6) Shutdown and restart Tomcat.

7) From your web browser, enter the following url:

http://localhost:8080/Sybase

-----------------------------------------------------------

Text of file "web.xml"

----------------------

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<welcome-file-list>

<welcome-file> /jsp/sybase.jsp </welcome-file>

</welcome-file-list>

<!-- for using dscp -->

<resource-ref>

<res-ref-name> jdbc/a_sybase_datasource </res-ref-name>

<res-type> javax.sql.DataSource </res-type>

<res-auth> Container </res-auth>

</resource-ref>

</web-app>

END_OF_TEXT(web.xml)

Text of file "sybase.jsp"

-------------------------

<%@ page import="java.sql.*" %>

<%@ page import="javax.sql.*" %>

<%@ page import="javax.naming.*" %>

<%@ page import="java.util.*" %>

<html>

<head> <title> Testing Sybase DataSource </title> </head>

<body bgcolor="white">

<font size=4>

<h3> Start of Test </h3>

<%

String s = "java:comp/env";

String t = "jdbc/a_sybase_datasource";

InitialContext initCtx = null;

try

{

initCtx = new InitialContext();

out.println("<p>initCtx = new InitialContext() : successful");

out.println("<BR>");

out.println( initCtx );

}

catch (Exception e)

{

out.println("<p>initCtx = new InitialContext() : failed");

out.println("<BR>");

out.println ( e );

}

Context envCtx = null;

try

{

envCtx = (Context) initCtx.lookup( s );

out.println("<BR>envCtx = initCtx.lookup(" + s + ") : successful");

out.println("<BR>");

out.println( envCtx );

}

catch (Exception e)

{

out.println("<BR>envCtx = initCtx.lookup(" + s + ") : failed");

out.println ( e );

}

DataSource ds = null;

ds = null;

try

{

out.println("<p>Trying ds=(DataSource)envCtx.lookup(" + t + ")");

ds = (DataSource) envCtx.lookup( t );

out.println("<BR>DataSource lookup apparently successful");

out.println("<BR>" + ds );

}

catch (Exception e)

{

out.println("<BR>Datasource lookup failed <BR>");

out.print( e );

}

if (ds == (DataSource) null)

{

out.println("<BR>DataSource null\n");

}

try {

Connection conn = ds.getConnection();

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery("select db_name()");

while (rs.next())

{

out.println

( "<BR>Inside fetch loop:" );

out.println

( "<BR>Value Returned from DataSource: " +

rs.getString(1) );

} // end_while

rs.close();

stmt.close();

conn.close();

} // end_try

catch (SQLException sqe) {

out.println("<BR>Inside catch(SQLException sqe)");

out.println( sqe.getMessage() );

} // end catch SQLException

catch (Exception e) {

out.println("<BR>Inside catch(Exception e)<BR>");

out.println(e.getMessage());

out.print( e );

} // end catch Exception

%>

<p>

<h3> End of Test </h3>

</font>

</body>

</html>

END_OF_TEXT(sybase.jsp)

Text of file "server.xml.SybaseDelta"

-------------------------------------

<!-- Sybase Example Context - dscp example -->

<Context path="/Sybase"

docBase="sybase"

debug="5"

reloadable="true"

crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"

prefix="localhost_Sybase.log."

suffix=".txt"

timestamp="true"/>

<Resource name="jdbc/a_sybase_datasource"

auth="Container"

type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/a_sybase_datasource">

<parameter>

<name>factory</name>

<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>

</parameter>

<parameter>

<name>maxActive</name>

<value>10</value>

</parameter>

<parameter>

<name>maxIdle</name>

<value>5</value>

</parameter>

<parameter>

<name>maxWait</name>

<value>10000</value>

</parameter>

<parameter>

<name>driverClassName</name>

<value>com.sybase.jdbc2.jdbc.SybDriver</value>

</parameter>

<parameter>

<name>url</name>

<value>jdbc:sybase:Tds:database_hostname:5000/your_dbname</value>

</parameter>

<parameter>

<name>username</name>

<value>your_userid</value>

</parameter>

<parameter>

<name>password</name>

<value>your_password</value>

</parameter>

</ResourceParams>

</Context>

<!-- END Sybase Example Context - dscp example -->

END_OF_TEXT(server.xmlSybaseDelta)

Resolution:

j"Tips and Workarounds", above, describes an example Sybase datasource definition, complete with a test jsp.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
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- 王朝網路 版權所有