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
运行就是上面红色部分异常
大侠,为啥啊?
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
运行就是上面红色部分异常
大侠,为啥啊?
解决方案 »
- 如何或者list占用了多少内存
- spring_security集群登录状态不确定问题
- 看看这个sql怎么写
- 关于Struts
- jdbc连接数据库的问题
- 用myeclipse做表映射时这个是什么意思Generate support for ListedTable(fk)->UnlistedTable and UnlistedTable(fk)->ListedTable
- 求Struts in Action免费下载地址(100分)
- 如何取得一个文件的详细信息(size,atime,mtime..)?
- jb+wlc执行测试时候报错
- JQUERY遍历打包前台数据JSON
- 求解释! 断点调试 怎么都不对, 能不能解决一下,
- 我想改变.properties里属性的值,但是为啥还是原来的值呢,求高手解答啊
自己又弄好了 等了好久没人回我啊