cancel
Showing results for 
Search instead for 
Did you mean: 

jdbc and SQLServer

Former Member
0 Kudos

I am trying to connect to a SQLServer database from my servlet using jdbc connectivity. I am able to connect to the db if I create a datasource. but if I try to make a connection by giving the connection string (DriverManager.getConnection(..)), I am getting an SQLException "No driver found" at Class.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver). I tried registering the driver using DriverManager.registerDriver(...) command, then I get NoClassDefFound error. I think it is a problem related to ClassLoader. I can see the deployed driver files in VA under the ClassLoader Viewer. Any idea what's going on here.

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

which version of SQL server r u using?

regards

shyam.

Former Member
0 Kudos

We are using SQL Server 2000.

Thanks.

Former Member
0 Kudos

Hi Meenu:

To register de driver the only thing that you have to do it. is the next:

String driverClassName = "com.sap.portals.jdbc.sqlserver.SQLServerDriver";

try {

Driver driver = (Driver) Class.forName (driverClassName).newInstance();

DriverManager.registerDriver(driver);

drivers.addElement(driver);

System.out.println("Registered JDBC driver " + driverClassName);

} catch (Exception e) {

System.out.println("Can't register JDBC driver: " + driverClassName + ", Exception: " + e);

}

The drivers comes in the the next jars:

P9sqlserver.jar

P9util.jar

P9base.jar

sapdbc.jar

Good luck!!!

Joshua

Former Member
0 Kudos

Josue,

Thanks for the reply. Where can I find these jars. I could not find any of P9 jars in WebAS 6.40. I could find sapdbc.jar though but it did not have SQLServerDriver.class.

Also, I wonder what is the diff between connecting to the db by creating a datasource vs passing the the connection string. i.e. dataSource.getConnection(...) vs DriverManager.getConnection(..).Which is a better approach.

Thanks.