Link to home
Start Free TrialLog in
Avatar of webview
webview

asked on

JDBC ODBC Bridge problem

I am trying to get a simple JSP page (using Sun's J2EE 1.3beta and JDK 1.3.0_02) to work with the JDBC/ODBC bridge on Windows 2000 Pro with SQL Server 2000.

Everytime I try to create the connection, I get a "No suitable driver" error.  I have search through Deja and my error seems pretty straightforward, but I still can't get it to work.

I have created a DSN named "movie" that accesses my SQL Server2K database on my local machine using userid=sa, password="".

The code for the JSP is:

<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page import="java.io.*" %>

<%
try
{
     Connection conn;
               
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               
     conn = DriverManager.getConnection("jdbc:odbc:movie", "sa", "");
}
catch( Exception e )
{
     out.println("Error loading the database driver:" + e.getMessage());
     return;
}

---

As soon as it gets to DriverManager.getConnection, an exception is thrown ("No suitable driver").

Any ideas?

Avatar of michelvdh
michelvdh

Hi WebView,

the "no suitable driver" message usually comes due to a mistake in your classpath variable. If your database is accessible from any other ODBC client (try with msaccess for example), then this is probably worth to check the config of your JSP engine.

Michel.
Avatar of webview

ASKER

I thought of this, however I don't have a CLASSPATH variable.  I am fairly new to Java, but from reading the docs, it sounds like CLASSPATH is just for external JARs and classes (i.e. not included with the Java framework).

I have installed both J2EE and JDK and I still don't have any classpath vars.  I have a ton of others (like CPATH) but no classpath.

Where should this CLASSPATH variable point to for the ODBC bridge?  I think the classes are in the \jdk13\jre\lib\rt.jar file.
You haven't specified the user name and passwd for the same.
Hey WebView

Stop your server
Please include your classpath in the server properties file.
I have done it for 1.2 and i think it is same for 1.3

Please update your classpath in userconfig.bat of j2ee.Please include it.
I think u problem will be solved.

u don't need to include it in autoexec.bat


Shyam
Hey WebView

Stop your server
Please include your classpath in the server properties file.
I have done it for 1.2 and i think it is same for 1.3

Please update your classpath in userconfig.bat of j2ee.Please include it.
I think u problem will be solved.

u don't need to include it in autoexec.bat
restart your server

Shyam
Avatar of webview

ASKER

What exactly do I have to add and to what?

There is a J2EE_CLASSPATH in userconfig.bat, is this it?

What do I add (specifically)?  The path to where the rt.jar is (i.e. d:\jdk13\jre\lib) ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Neutron
Neutron

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webview

ASKER

That still didn't work.   I get the "no suitable driver" error.

I downloaded the latest Orion appserver (www.orionserver.com) and it worked perfectly right away (with no configuration changes).

Thanks for your help.

Hey Webview

    I hope,this problem occured only because of not setting the variable in one of the properties file.

Under the j2sdkee1.3/config directory there is a file called "default.properties". Open that in wordpad and change the fields with new values

 
jdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver
jdbc.datasources=jdbc/MSAccess|jdbc:odbc:<DSN Name>;create=true

                     
Restart your J2EE server. It will show the jndi binding name as jdbc/MSAccess

Hope this will work..

Regards
Jim
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between shyamkumarreddy and Neutron

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

MaheshExp
EE Cleanup Volunteer