GWT performs step-by-step debugging on the complete instance of the customer and service in eclipse and Tomcat (database connection pool)-Tomcat data connection pool (Oracle10g)

Source: Internet
Author: User
Tomcat5.5 database connection pool configuration (Oracle10g)

Note: The reference is not remembered (a lot of changes have been made on the basis of the original), so there is no reference

Webapps has the following directory structure and files (if not, create one by yourself)

+ --- TT
| Test. jsp
| + --- META-INF
|/--- WEB-INF
| Web. xml
| + --- Classes
|/--- Lib

1. Use the JDBC driver of Oracle (jdbc14.jar, which may be a pure Java driver for different configuration methods)
Copy to the Tomcat directory "common/Lin"

2. open the file "CONF/server. xml" and add the following Configuration:
<Resource
Name = "JDBC/webedi"
Type = "javax. SQL. datasource"
Password = "webedi" password used to log on to the database
Driverclassname = "oracle. JDBC. oracledriver"
Maxidle = "2"
Maxwait = "5000"
Username = "webedi" database username
Url = "JDBC: oracle: thin: @ 192.168.1.11: 1521: kferp" Database URL
Maxactive = "4"/>
For details about each parameter, see the Tomcat help documentation.

Here is another method (requires that "admin" has been downloaded and deployed ")
A. Enter "http: // local: 8080/admin" in the browser and enter the Tomcat password to enter the next interface.
B. Click "Resources" under the root Branch (which must be the root branch"
C. Click data sources"
D. Select "create new datasource" in "Data Source actions" on the right"
E. The correct content is the same as the content configured manually above.
F save ("save ")
G submit change ("commit change ")

3. open the file "CONF/context. xml" and add the following Configuration:
<Resourcelink name = "JDBC/webedi" Global = "JDBC/webedi" type = "javax. SQL. datasource"/>
Note: The value of "global" must be the same as the value of "name" configured in step 2. The value of "name" in this step can be customized.

4. Modify the web application configuration file "Web. xml" and add the following Configuration:
<Resource-ref>
<Res-ref-Name> JDBC/webedi </RES-ref-Name>
<Res-type> javax. SQL. datasource </RES-type>
<Res-auth> container </RES-auth>
</Resource-ref>

5. Compile the test. jsp file as follows:
<% @ Page contenttype = "text/html; charset = GBK" %>
<% @ Page import = "Java. SQL .*,
Javax. Naming. * "%>
<%
Try {
Context initctx = new initialcontext ();
Context CTX = (context) initctx. Lookup ("Java: COMP/ENV ");
Object OBJ = (object) CTX. Lookup ("JDBC/webedi ");
Javax. SQL. datasource DS = (javax. SQL. datasource) OBJ;
Connection conn = Ds. getconnection ();
Statement stmt = conn. createstatement (Java. SQL. resultset. type_scroll_insensitive,
Java. SQL. resultset. concur_read_only );
String strsql = "select * From f_forecast_line ";
Resultset rs = stmt.exe cutequery (strsql );
Out. println ("ASDFASDF ");
For (; RS. Next ();)
{
Out. println (Rs. tostring ());
}
%>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
...
</Html>
<%
Rs. Close ();
Stmt. Close ();
Conn. Close ();
} Catch (exception e ){
E. printstacktrace ();
Throw E;
}
%>

6. Restart Tomcat

7. Enter "http: // localhost: 8080/TT/test. jsp" in the browser"

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.