日期:2014-05-20 浏览次数:21212 次
package com.abc.sqlserver; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class TestSqlserver { /** * * @param args */ public static void main(String[] args) { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } String connectionUrl = "jdbc:sqlserver://localhost:1433;" + "databaseName=Test;"; try { Connection con = DriverManager.getConnection(connectionUrl,"sa","pwd"); // System.out.println( con.isClosed()); // con.close(); } catch (SQLException e) { e.printStackTrace(); } System.out.println("done"); } }