62,614
社区成员
发帖
与我相关
我的任务
分享
Unhandled exception type ClassNotFoundException
public static Connection getConnection() throws SQLException, IOException
{
Properties props = new Properties();
FileInputStream in = new FileInputStream("database.properties");
props.load(in);
in.close();
String drivers = props.getProperty("jdbc.drivers");
if (drivers != null) System.setProperty("jdbc.drivers", drivers);
String url = props.getProperty("jdbc.url");
String username = props.getProperty("jdbc.username");
String password = props.getProperty("jdbc.password");
Class.forName("oracle.jdbc.driver.OracleDriver");//ClassNotFoundException
return DriverManager.getConnection(url, username, password);
}
#jdbc.drivers=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:xe
jdbc.username=school
jdbc.password=school