Z
zhjwjan
Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序在unix或linux下连接oracle数据库,使用classes111.zip连接时出现“Exceding key size”的错误;当使用classes12.zip时,出现java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver的错误,请问为什么用classes111.zip可以找到oracle.jdbc.driver.OracleDriver,但出现
“Exceding key size”的错误,而用classes12.zip就找不到oracle.jdbc.driver.OracleDriver呢?我在windows下完全没问题的。
import java.io.*;
import java.sql.*;
import java.lang.*;
public class OracleTest{
public static void main(String[] args) {
String host = null;
String port = null;
String sid = null;
String pwd = null;
String user = null;
try {
BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Oracle connection test, please input the following info:");
System.out.print("host:");
host = bin.readLine();
System.out.print("port:");
port = bin.readLine();
System.out.print("sid:");
sid = bin.readLine();
System.out.print("user:");
user = bin.readLine();
System.out.print("password:");
pwd = bin.readLine();
bin.close();
}
catch (IOException e) {
System.err.println("Error: "+e.getMessage());
}
String driver="oracle.jdbc.driver.OracleDriver";
String url = "jdbcracle:thin"+ host +":" + port + ":" + sid ;
System.out.println();
System.out.println(driver);
System.out.println(url);
System.out.println("user:"+user+" pwd:"+pwd);
System.out.println();
try {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pwd);
System.out.println("Connection to oracle succeeded");
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
java -classpath .:classes12.zip OracleTest
“Exceding key size”的错误,而用classes12.zip就找不到oracle.jdbc.driver.OracleDriver呢?我在windows下完全没问题的。
import java.io.*;
import java.sql.*;
import java.lang.*;
public class OracleTest{
public static void main(String[] args) {
String host = null;
String port = null;
String sid = null;
String pwd = null;
String user = null;
try {
BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Oracle connection test, please input the following info:");
System.out.print("host:");
host = bin.readLine();
System.out.print("port:");
port = bin.readLine();
System.out.print("sid:");
sid = bin.readLine();
System.out.print("user:");
user = bin.readLine();
System.out.print("password:");
pwd = bin.readLine();
bin.close();
}
catch (IOException e) {
System.err.println("Error: "+e.getMessage());
}
String driver="oracle.jdbc.driver.OracleDriver";
String url = "jdbcracle:thin"+ host +":" + port + ":" + sid ;
System.out.println();
System.out.println(driver);
System.out.println(url);
System.out.println("user:"+user+" pwd:"+pwd);
System.out.println();
try {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pwd);
System.out.println("Connection to oracle succeeded");
conn.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
java -classpath .:classes12.zip OracleTest