aspose file tools*
The moose likes JDBC and the fly likes JSP connection to MS Access DB - No suitable driver exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JSP connection to MS Access DB - No suitable driver exception" Watch "JSP connection to MS Access DB - No suitable driver exception" New topic
Author

JSP connection to MS Access DB - No suitable driver exception

Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
Hi,

I am trying to connect to MS Access DB through a jsp, but i get following error
"java.sql.SQLException: No suitable driver "
JSP Code
--------
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dataSourceName = "mdbTEST";
String dbURL = "jdbcdbc:" + dataSourceName;
java.sql.Connection connection = java.sql.DriverManager.getConnection(dbURL);
%>


but when i write a stand alone java application with the same code and run it, it works fine
Stand Alone Java application code
----------------------------------
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String dataSourceName = "mdbTEST";
String dbURL = "jdbcdbc:" + dataSourceName;
Connection con = DriverManager.getConnection(dbURL);


Can someone pls tell , where I am going wrong

Thanks & Regards.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Ratan,
Is the driver jar file in your server's classpath?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
Hi,
Firstly thanks for your reply.

Environment: WSAD 5.1, websphere test server 5.1

I have put rt.jar in server's classpath by double clicking server->environment

is MS Access compatible with WSAD 5.1?
Does JRE version come into picture?

Thanks in advance
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Ratan,

I remember a simular problem from 2 years ago: a webapplication with a MS-Access databases worked fine in the testenvironment of Websphere 5.0, but not in Websphere 5.1

The rt.jar in Websphere 5.1 did not have JDBC-ODBC bridge in it (JdbcOdbcDriver class etc).

Herman
PS this webapp was only for educational purposes, so we stayed at Websphere 5.0
Ratan Kumar
Ranch Hand

Joined: Jul 19, 2006
Posts: 67
Thanks for your reply.

The rt.jar which I have in my classpaths for appln and server has JdbcOdbcDriver class. I have verified that.

SO what can be the reason, its working in stand alone java application and not in a test jsp?
Zein Nunna
Ranch Hand

Joined: Mar 31, 2005
Posts: 245
Ratan,

I've used MS Access with JSP's/Servlets. I had a similar problem with the jar's.

Two points to note:
1/Use a proper database i.e. MySQL or something rather than MS Access
2/I connected to MS Accees by going to Control Panel --> Administartive tools --> Datasources (ODBC) - click on this then add on the system tab and add your datasource, this should work.

Regards
Zein
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP connection to MS Access DB - No suitable driver exception