请问Java 怎么 与 SQL Server2005 连接,请给一个完整的连接字符和驱动。

解决方案 »

  1.   

    请问Java 怎么 与 SQL Server2005 连接,请给一个完整的连接字符和驱动。
      

  2.   

    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    Connection conn = DriverManager.getConnection(
    "jdbc:sqlserver://localhost;DatabaseName=Stephen;SelectMethod=cursor", "sa", "sally");
    我是这么写的,请问怎么错了!
      

  3.   

    首先要导入连接驱动的那三个包try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
    conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind", "sa", "");
        }catch (Exception e) {
    e.printStackTrace();
        }
      

  4.   

    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    Connection conn = DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Stephen,"sa", "sally");
      

  5.   

    com.microsoft.sqlserver.jdbc.SQLServerDriver和
    jdbc:sqlserver://localhost;DatabaseName=Stephen;SelectMethod=cursor
    这里错了,少了jdbc如下:
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    jdbc:microsoft:sqlserver://
      

  6.   

    各位大虾,我连接的是SQL Server 2005 你们说的好像是2000
      

  7.   

    java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
      

  8.   

    sql2005Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
    String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
       "databaseName=AdventureWorks;user=MyUserName;password=1111;";
    Connection con = DriverManager.getConnection(connectionUrl);
      

  9.   

    To work around this issue, load the 2005 version of the JDBC driver
    class first, as follows:Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // 2005 version
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // 2000 versionThis will ensure that the "jdbc:sqlserver://" URL prefix is handled
    by the 2005 version of the JDBC driver and the "jdbc:microsoft:sqlserver://"
    URL prefix is handled by the 2000 version of the JDBC driver.
      

  10.   

    首先要导入连接驱动的那三个包try {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
    conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Northwind", "sa", "");
        }catch (Exception e) {
    e.printStackTrace();
        }
      

  11.   

    Sql Server 2005 好像就一个驱动包!
      

  12.   

    jdbc:odbc:Driver={SQL Server};Server=(local);uid=sa;pwd=;Database=test