jsp(SUN企業級應用的首選)通過JDBC與Oracle(大型網站數據庫平台)相連
一、環境變量(系統變量)
JAVA_HOME = C:JDK1.3
tomcat(一個很好用的JSP運行平台)_HOME = C: omcat(一個很好用的JSP運行平台)-3.2.3
ClassPath = D:Oracle(大型網站數據庫平台)Ora81jdbclibclasses12.zip(JDBC驅動程序)
二、測試程序
<%@ page language="java" import="java.io.*,java.sql.*,javax.sql.* ,javax.naming.*"%>
<%@ page contentType="text/html;charset=gb2312" %>
<%
String sDBDriver = "Oracle(大型網站數據庫平台).jdbc.driver.Oracle(大型網站數據庫平台)Driver";
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(":"+"<br>");
//out.println(" + rs.getString(answers) + ");
}
rs.close();
}
catch(Exception e)
{
out.println(e);
}