Tomcat5.5 connection pool Configuration

Source: Internet
Author: User

Tomcat 5.5AndTomcat5.0The configurations are different., Tomcat5.5The configuration is as follows::

In Server. xml The configuration in the file is as follows: :

<Context Path = "/recommend" reloadable = "true" docbase = "C: \ eclipse \ workspace \ recommend" workdir = "C: \ eclipse \ workspace \ recommend \ work">

<Resource Name = "JDBC/myoracle" auth = "Container" type = "javax. SQL. datasource"

Maxactive = "100" maxidle = "30" maxwait = "10000"

Username = "spstest" Password = "sps0922"

Driverclassname = "oracle. JDBC. Driver. oracledriver"

Url = "JDBC: oracle: thin :@ 192.168.6.15: 1521: ora9"/>

</Context>

In C: \ Tomcat 5.5 \ common \ Lib Directory Class12.jar

Class12.jarYesOracleOfJDBCDriverProgramNo package

 

In Web. xml ModifyingCode

<Description> oralcedb </description>

<Resource-ref>

<Description> dB connection </description>

<Res-ref-Name> JDBC/myoracle </RES-ref-Name>

<Res-type> javax. SQL. datasource </RES-type>

<Res-auth> container </RES-auth>

</Resource-ref>

 

Test code

<% @ Page import = "javax. Naming. Context" %>

<% @ Page import = "javax. SQL. datasource" %>

<% @ Page import = "javax. Naming. initialcontext" %>

<% @ Page import = "Java. SQL. *" %>

<%

  Datasource DS = NULL;

Context jndicntx = new initialcontext ();

  DS = (datasource) jndicntx. Lookup ("Java: COMP/ENV/jdbc/myoracle ");

If (Ds! = NULL ){

 System. Out. println ("connection is OK! ");

 }

Else

{

System. Out. println ("connection is fail! ");

}

Connection Cn = Ds. getconnection ();

If (CN! = NULL ){

System. Out. println ("CN is OK! ");

}

Else

{

System. Out. println ("CN is fail! ");

}

// Statement stmt = cn. createstatement ();

// Resultset rst = stmt.exe cutequery ("select * from book ");

//Out. println ("<p> RST is OK! "+ RST. Next ());

//While (RST. Next ()){

//System. Out. println ("<p> book_code:" + RST. getstring (1 ));

//}

CN. Close ();

 

%>

Related Article

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.