Home > database >  Oracle tomcat configuration
Oracle tomcat configuration

Time:09-20

Change..
/conf/content. XML

<? The XML version='1.0' encoding="utf-8"?>


WEB - INF/WEB. Xml

- & gt;

On the session expiration as well as a webapp lifecycle) - & gt;
- & gt;
DriverClassName="oracle JDBC. OracleDriver" url="JDBC: oracle: thin: @ IP: 1521: wouldn"
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"?>
XMLNS="http://java.sun.com/xml/ns/javaee" XMLNS: web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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;
Hpms

Index. Jsp


Java JDBC
The JDBC/oracle
Javax.mail. SQL. DataSource
Container



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;


My JSP 'tomcatTest. JSP' starting page

<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!!!!!!!!!!
  • Related