JDBC连接MySQL和Oracle

[复制链接]
查看11 | 回复0 | 2020-4-19 15:48:28 | 显示全部楼层 |阅读模式
1.Oracle连接语句://对应class12.jarString driver="oracle.jdbc.driver.OracleDriver";String url="jdbc:oracle:thin:@localhost:1521:test";
//...........:oci8:@localhost:1521:test
Connection con=null;try{Class.forName(driver);con=DriverManager.getConnection(url,"scott","tiger");}catch(ClassNotFoundException){ }catch(SQLException){}2.SQL连接语句://对应jtds.jarString driver="net.sourceforge.jtds.jdbc.Driver";String url="jdbc:jtds:sqlserver://localhost:1433/test";Connection con=null;try{Class.forName(driver);con=DriverManager.getConnection(url,"sa","");}catch(ClassNotFoundException){ }catch(SQLException){}3.Mysql连接语句://对应mm.mysql-2.0.4-bin.jarString driver="org.gjt.mm.mysql.Driver";String url="jdbc:mysql://localhost:3306/zxks";
try { Class.forName(driver); con=DriverManager.getConnection(str,"root","");} catch (ClassNotFoundException e) { // TODO 自动生成 catch 块 e.printStackTrace();} catch (SQLException e) { // TODO 自动生成 catch 块 e.printStackTrace();}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行