jdbc连接sql server2005怎么配置

解决方案 »

  1.   

    http://download.csdn.net/source/446965
      

  2.   


    String dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";     String url = "jdbc:sqlserver://localhost:1433;DatabaseName=db";      Connection connection = null;
    try {
    Class.forName(dbDriver).newInstance();
    connection = DriverManager.getConnection(url,"sa","123456");
    System.out.println("成功");
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    System.out.println("数据库加载失败");
    }
        
        }
      

  3.   

    1. 把 jdbc 驱动包拷贝到你工程的 Web-Root/WEB-INF/lib 文件夹下.2. String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
       String url = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=user"; 
       Connection connection = null;
       PreparedStatement pstmt = null;
       try {
           Class.forName(dbDriver);
           connection = DriverManager.getConnection(url,"sa","sa");
           String preparedSql = "select * from user";
           pstmt = conn.prepareStatement(preparedSql);         
           System.out.println("连接数据库成功");
       } catch (SQLException e) { 
           e.printStackTrace();
           System.out.println("连接数据库失败");
       }        
    }