on 04-20-2006 8:31 PM
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.
hi,
which version of SQL server r u using?
regards
shyam.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.