• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP connection to MS Access DB - No suitable driver exception

 
Ratan Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34208
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ratan,
Is the driver jar file in your server's classpath?
 
Ratan Kumar
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic