/conf/content. XML
<? The XML version='1.0' encoding="utf-8"?>
On the session expiration as well as a webapp lifecycle) - & gt;
The username="username", "=" password "maxActive=" 5 "maxIdle=" 2 "maxWait=" 10000 "/& gt;
And will ojdbc6. Copy the jar into the tomcat lib directory, the above is configured the Oracle data source,
In need on the web. When using XML to add:
<? The XML version="1.0" encoding="utf-8"?>
Xsi: schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
Id="WebApp_ID" version="2.5" & gt;
Example:
The index. The JSP
Press Ctrl + C to copy the code
<% @ page language="Java" import="Java. Util. *" pageEncoding="utf-8" % & gt;
<% @ page import="Java. SQL. *, javax.mail. SQL. *, javax.mail. Naming. *" % & gt;
<body>
<%
The Context CTX=new InitialContext ();
DataSource ds=(CTX DataSource)
Lookup (" Java: comp/env/JDBC/oracle ");
The Connection con=ds. GetConnection ();
The Statement st=con. CreateStatement ();
The ResultSet rs=st. executeQuery (" select * from VENDORCLASS ");
While (rs), next ()) {
Out.println (" & lt; H1 & gt;" + rs. Get string (2) + "& lt;/h1 & gt;" );
}
rs.close();
St. close ();
Con. The close ();
% & gt;
Press Ctrl + C to copy the code
Browser to access:
Reprint please indicate the source, thank you
CodePudding user response:
This is what to do?CodePudding user response:
No see!!!!!!!!!!