I have a JAVA Class that's trying to connect to a MS SQL database. Now, when I am trying to connect to the database I got an error "No suitable driver found for....."
Why is this happening?
Here is the code.
DB db = bew DB();
db.dbConnect();
...
class DB
{
public void dbConnect() {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connectionUrl = "jdbc:sqlserver://web.address.com;" +
"databaseName=testdb;user=user.name;password=*****;";
Connection con = DriverManager.getConnection(connectionUrl);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
I used sqljdbc.jar as my driver and I added it on my classpath.