//ora816是数据库连接串
strurl="jdbc:oracle:thin:@192.168.192.119:1521:ora816";
straccount="user";
strpassword="password";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
sqlConn=DriverManager.getConnection(strurl,straccount,strpassword);
}
catch(Exception e)
{
}
再连接不上就是你的连接串有问题或是classes12.zip或classes111.zip不在classpath中。
strurl="jdbc:oracle:thin:@192.168.192.119:1521:ora816";
straccount="user";
strpassword="password";
try
{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
sqlConn=DriverManager.getConnection(strurl,straccount,strpassword);
}
catch(Exception e)
{
}
再连接不上就是你的连接串有问题或是classes12.zip或classes111.zip不在classpath中。
[%@ page import="java.sql.*" %]
[html]
[body]
[%
try{
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ora8", "username", "password");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select tname from tab ");
while(rs.next())
out.println(rs.getString(1)+"<br>");
}
catch(Exception e){ System.out.println(e);}
%]
[/body]
[/html]