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!