加classes111.zip到classpath
============================
测试程序
==========================
import java.sql.*; public class connectToOracle extends java.applet.Applet {
Driver driver;
Connection conn = null;
static String driverUsed =
"oracle.jdbc.driver.OracleDriver";
static String serverAddress =
"jdbc:oracle:thin:scott/[email protected]:1243:myInstance";
// jdbc:oracle:thin is the driver used
// scott/tiger is user/password
// www.myServer.com is the same machine from where the Applet was loaded
// 1234 is the port used
// myInstance is where my data is public void init(){
makeConnection(serverAddress);
}
public void makeConnection(String svr) {
try {
System.out.println("Loading ... " + driverUsed);
driver =
(Driver)Class.forName(driverUsed).newInstance();
System.out.println("Connecting ... " + svr);
conn =
DriverManager.getConnection(svr);
System.out.println("Ready.");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
============================
测试程序
==========================
import java.sql.*; public class connectToOracle extends java.applet.Applet {
Driver driver;
Connection conn = null;
static String driverUsed =
"oracle.jdbc.driver.OracleDriver";
static String serverAddress =
"jdbc:oracle:thin:scott/[email protected]:1243:myInstance";
// jdbc:oracle:thin is the driver used
// scott/tiger is user/password
// www.myServer.com is the same machine from where the Applet was loaded
// 1234 is the port used
// myInstance is where my data is public void init(){
makeConnection(serverAddress);
}
public void makeConnection(String svr) {
try {
System.out.println("Loading ... " + driverUsed);
driver =
(Driver)Class.forName(driverUsed).newInstance();
System.out.println("Connecting ... " + svr);
conn =
DriverManager.getConnection(svr);
System.out.println("Ready.");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
装oracle 8i吧,最好还是8.1.6以后的。8i才支持xml 和数据库 resultset或者query 转换的
java api
版本要对应,这是我的痛苦经历