no suitable driver

刚装了M$新的jdbc驱动,就出了个no suitable driver错误.
做了个方案大家可以参考一下,除了和for 2000的字符串有一点不同外,用的Class有也不同,这个大家要注意

package com.cyberport.beans;


import java.sql.*;
 

public class ConnectionDB {

    Connection con 
= null;
    
public ConnectionDB(){
        
    }

     
    
    
public Connection getConnectionDB()
    
{
        
        String driverName 
= "com.microsoft.sqlserver.jdbc.SQLServerDriver"
        String ConnectionString 
= "jdbc:sqlserver://local;database=YourDatabaseName;";
        String userName 
=  "UserName";
        String userPwd 
=   "PassWrod";

        
try 
        Class.forName(driverName); 
        con 
= DriverManager.getConnection(ConnectionString, userName, userPwd); 
        
//System.out.println("Connection Successful!"); 
        }
 
        
catch (Exception e) 
        e.printStackTrace(); 
        }
 

      
return con;

    }

    
    
}
posted on 2006-02-13 12:39  microtea  阅读(4332)  评论(1编辑  收藏  举报