jtds1.1连接sqlserver2000测试示例_java

分享到:


public class TestSqlserverJtds {
 public static void main(String[] args) {
  Connection con=null;

        try
        {
            String driver="net.sourceforge.jtds.jdbc.Driver";
            String url="jdbc:jtds:sqlserver://192.168.0.15:1433;DatabaseName=test";
            Class.forName(driver).newInstance();
            System.out.println(" 连接开始。。。。。。");
            long starttime = System.currentTimeMillis();
            con =DriverManager.getConnection(url,"sa","123");
            long endtime = System.currentTimeMillis();
            System.out.println(" 连接成功 !Lost time:" + (endtime - starttime) / 1000 + "秒");

            con.close();
        } catch(Exception e) {
            e.printStackTrace();
        } finally{
         try {

          if(null != con){
           con.close();
          }
         } catch (SQLException e) {
    e.printStackTrace();
   }
        }
 }
}

昵    称:
验证码:

相关文档: