在使用java连接服务器时出错:org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null',是什么原因?

解决方案 »

  1.   

    connect URL  'null '
      

  2.   

    import java.sql.*;
    public class TestSQL2005
    {
        private Connection con=null;
        //使用SQL 2000时三个包放在C:\Program Files\Java\jdk1.5.0_09\jre\lib\ext中
        private static final String DRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";
        private static final String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=netshop";//netshop 是数据库名
        String us="sasa";//us是用户名
        String pw="123456";//密码
        public void testConnection()
        {
            try
            {
                Class.forName(DRIVER);
                con=DriverManager.getConnection(URL,us,pw);
                System.out.print("Connection Successfull!"); 
                if(con!=null)
                {
                    System.out.println("OK!");
                    con.close();
                }
           }
           catch (ClassNotFoundException e)
           {
               e.printStackTrace();
           }
           catch(SQLException e)
           {
               e.printStackTrace();
           }
        }
        public static void main(String[] args)
        {
            new TestSQL2005().testConnection();
        }
    }