你没有加载驱动程序。加载方式可如下所示:
加载jdbc-odbc桥;
Class.forName("jdbc.odbc.driver.JdbcOdbcDriver");
或者加载jdbc驱动
Class.forName("com.microft.driver.SqlServerDriver");
该class具体的我忘了,你查一下。
加载jdbc-odbc桥;
Class.forName("jdbc.odbc.driver.JdbcOdbcDriver");
或者加载jdbc驱动
Class.forName("com.microft.driver.SqlServerDriver");
该class具体的我忘了,你查一下。
出现了ClassNotFoundException
import java.util.*;
import java.io.*;
public class JTCDBConnectionF implements Serializable{
protected Connection con = null;
public JTCDBConnectionF() { }
public void dbOpen() throws java.lang.Exception{
if (con == null || con.isClosed()) {
String url = "jdbc:oracle:oci8:@apsv";
String user = "scott";
String pass = "tiger";
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con = DriverManager.getConnection(url,user,pass);
con.setTransactionIsolation( con.TRANSACTION_READ_COMMITTED );
con.setAutoCommit(false); System.out.println("DB OPEN");
} else {
System.out.println("OPENED DB");
}
}
public JTCerrorF dbClose() {
try {
if (con != null && !con.isClosed()) {
con.rollback();
con.close();
System.out.println("DB CLOSE");
} else {
System.out.println("CLOSED DB");
}
}
catch (SQLException se) {
// return new JTCerrorF(se.getErrorCode(),se);
return new JTCerrorF("PD05",se); //DB CLOSE
}
finally {
con = null;
}
return (JTCerrorF)null;
}
}
是根据后面的字符串返回这个类的对象,你没有装这个驱动当然出现
ClassNotFoundException
2. 你没有把jdbcodbcdriver库放在你的工程中呀!
3. Class.forName("jdbc.odbc.driver.JdbcOdbcDriver");
是根据后面的字符串返回这个类的对象,你没有装这个驱动当然出现
ClassNotFoundException
4.你是否有msbase.jar
mssqlserver.jar
msutil.jar这几个文件,如果没有,说明没有安装jdbc驱动,
5.还可能语法错误,一个一个字符的查找