JSP connects Oracle 9i

Source: Internet
Author: User
Tags stmt
Js|oracle

Recently, due to the project, the system needs to be transformed into another environmental system. That is, the Resin + Ms SQL developed JSP program into the WebLogic + Oracle JSP program. Oracle I played it six years ago, I forgot how to use it long ago. From the cooperation project company to get the genuine installation disk installed, suddenly do not know how to use JSP to connect Oracle. Open Search engine crazy search, the result is obviously Jdbc,thin code. Lazy man, take to test the test. It's not going to work. Depressed for one weeks, today, in search of time, accidentally found the same rookie stickers, according to the post instructions, the test succeeded. Now write here to be used as a collection.

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

My configuration environment is as follows

Oracle 9i + Resin $ + Windows Server 2003 + JDK1.5

Oracle 9i installation directory: F:\oracle

Oracle 9i

Machine Name: CHINA3CT

Service:master

Users: System

Password: zsk

Preparation: Copy (F:\oracle\ora92\jdbc\lib) Classes12.jar under the Oracle installation directory to the Web-inf \lib directory of Jdk\lib and Web sites

Source:

<%@ page contenttype= "text/html;charset=gb2312"%>
<%@ page import= "java.sql.*"%>
<body>
<%class.forname ("Oracle.jdbc.driver.OracleDriver"). newinstance ();
String url= "Jdbc:oracle:thin: @china3ct: 1521:master";
FILE://ORCL for the SID of your database
String user= "System";
String password= "Zsk";
Connection conn= drivermanager.getconnection (Url,user,password);
Statement stmt=conn.createstatement (resultset.type_scroll_sensitive,resultset.concur_updatable);
String sql= "SELECT * from Scott.dept";
ResultSet rs=stmt.executequery (SQL);
while (Rs.next ()) {%>
<%=rs.getstring (1)%>-<%=rs.getstring (2)%> <br>
<%}%>
<%out.print ("Successful database operation, congratulations");%>
<%rs.close ();
Stmt.close ();
Conn.close ();
%>
</body>

If it's true, it'll be there.

10-accounting
20-research
30-sales
40-operations
Database operation successful, congratulations!



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.