一个jdbc连接oracle8的例子(本机的页可以)!!!! - 中国WEB开发者网络 (http://www.webasp.net) -- 技术教程 (http://www.webasp.net/article/) --- 一个jdbc连接oracle8的例子(本机的页可以)!!!! (http://www.webasp.net/article/8/7027.htm) |
| -- 作者:未知 -- 发布日期: 2003-07-26 |
| try { //加载一个Oracle驱动 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); //使用OCI8连接到数据库 conn=DriverManager.getConnection("jdbc:oracle:oci8:@DatabaseName"+,"user","password"); }catch(SQLException e) { //捕捉SQL违例 System.out.println("Ora8iConnect在连接oracle8数据库时捕获"); while (e!=null) { System.out.println("SQLState:"+e.getSQLState()); System.out.println("Message :"+e.getMessage()); System.out.println("Vendor :"+e.getErrorCode()); e=e.getNextException(); System.out.println(" "); } conn=null; } try { Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); //orcl为你的数据库的SID String url="jdbc:oracle:thin:@localhost:1521:orcl"; Connection conn= DriverManager.getConnection(url,"user","password"); }catch(SQLException e) { //捕捉SQL违例 System.out.println("Ora8iConnect在连接oracle8数据库时捕获"); while (e!=null) { System.out.println("SQLState:"+e.getSQLState()); System.out.println("Message :"+e.getMessage()); System.out.println("Vendor :"+e.getErrorCode()); e=e.getNextException(); System.out.println(" "); } conn=null; } |
| webasp.net |