JSP透過JDBC與Oracle相連 (轉)

worldblog發表於2007-08-16
JSP透過JDBC與Oracle相連 (轉)[@more@]

透過JC與相連

一、環境變數(變數)

_HOME = C:1.3
_HOME = C:TOMCAT-3.2.3
ClassPath = D:OracleOra81libclasses12.zip(JDBC)

二、測試程式



String sDB = "oracle.jdbc.driver.OracleDriver";
String nnStr = "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(" * from veh_xzqj");
while (rs.next()){
out.println("" + rs.getInt(1) + "");
out.println(":"+"
");
//out.println(" + rs.getString('answers') + ");
}
rs.close();

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


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-962108/,如需轉載,請註明出處,否則將追究法律責任。

相關文章