String 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.jar
String 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.jar
String 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()
}
<driver-url>jdbc:mysql://localhost:3306/GBDSPT </driver-url><driver-class>com.mysql.jdbc.Driver</driver-class>
别忘了下驱动
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)