JSP is connected to Oracle via JDBC

zhaozj2021-02-16  47

JSP is connected to Oracle via JDBC

First, environment variable (system variable)

Java_home = c: /jdk1.3tomcat_home = c: /tomcat-3.2.3classpath = D: /oracle/ora81/jdbc/lib/classes12.zip (JDBC driver)

Second, the test procedure

<% @ page language = "java" import = "java.io. *, java.sql. *, javax.sql. *, javax.naming. *"%> <% @ page contenttype = "text / html; charSet = GB2312 "%> <% string sdbdriver =" oracle.jdbc.driver.Oracledriver "; string sconnstr =" JDBC: Oracle: Thin: @ 192.168.0.58: 1521: Orcl ";

Connection conn = null; ResultSet rs = null; Statement stmt = null; try {Class.forName (sDBDriver); conn = DriverManager.getConnection (sConnStr, "veh_admin", "oracle"); stmt = conn.createStatement (); / /stmt.executequery ("create Table AAA (AAA INT) "); // stmt.executeUpdate (" INSERT INTO BBB VALUES (456));

RS = stmt.executeQuery ("SELECT * from veh_xzqj"); while (rs.next ()) {out.println ("" rs.Getint (1) ""); out.println (":" "
"); //out.println (" rs.getstring ('answers') ");}}}}}}

} Catch (Exception E) {OUT.PRINTLN (E);

转载请注明原文地址:https://www.9cbs.com/read-25922.html

New Post(0)