日期:2014-05-19  浏览次数:20708 次

oracle数据库连接时出异常,求指教
package bank.server;

import java.util.*;
import java.io.*;
import java.sql.*;

import bank.MyException.MyException;

public abstract  class DatabaseConnection {
public Properties prop;
public static Connection conn =null;
public static PreparedStatement pst=null;
public static CallableStatement cst = null;
public static ResultSet rs  = null;

public Connection getConnection(){

try {
if(prop==null){
prop = new Properties();

prop.load(new FileReader(this.getClass().getResource("data.properties").getPath()));

}
Class.forName(prop.getProperty("driver"));
conn = DriverManager.getConnection(
prop.getProperty("url"),prop.getProperty("user"),prop.getProperty("password"));
}  
catch (FileNotFoundException e) {
throw new MyException("文件未找到,请检查文件是否存在!-----getConnection");
}catch (IOException  e) {
throw new MyException("文件在传输是出错-----getConnection");
} catch (ClassNotFoundException e) {
throw new MyException("未找到对应类 -----getConnection");
} catch (SQLException e) {
throw new MyException("建立连接时,出现错误-----getConnection");
}

return conn;

}

配置文件如下

driver=oracle.jdbc.driver.OracleDriver
user=ZH
password=123
url=jdbc\:oracle\:thin\:@localhost\:1521\:xe
运行就是上面红色部分异常
大侠,为啥啊?
------解决方案--------------------

自己又弄好了 等了好久没人回我啊
------解决方案--------------------
null