TXT

JTDS

By Esther Black,2014-11-13 23:43
12 views 0
JTDS

//前面需要import java.sql.*那些东西别忘记了

    Connection conn = null;

try {

     Class.forName("net.sourceforge.jtds.jdbc.Driver");

     Connection conn =

    DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/pubs", "sa",

    "sa的密码");

    } catch (SQLException ex) {

     ex.printStackTrace();

     conn = null;

    } catch (ClassNotFoundException ex) {

     ex.printStackTrace();

     conn = null;

    }

if(conn!=null) { //成功;

     System.out.println("success!!!!!"); } else { //失败。。。

     System.out.println("......."); }

Report this document

For any questions or suggestions please email
cust-service@docsford.com