JSP通过JDBC与Oracle相连

2008-02-23 07:49:28来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

一、环境变量(系统变量)

JAVA_HOME = C:\JDK1.3
TOMCAT_HOME = C:\TOMCAT-3.2.3
ClassPath = D:\Oracle\Ora81\jdbc\lib\classes12.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.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(":" "<br>");
//out.println(" rs.getString('answers') ");
}
rs.close();

}
catch(Exception e)
{
out.println(e);
}

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:JBuilder2005 Struts深度体验之改造

下一篇:初学者入门:Structs中基本配置入门