日期:2014-05-20 浏览次数:20706 次
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