Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC-ODBC Bridge & Servlet

843854Dec 4 2001 — edited Dec 5 2001
Hello all,

My problem can be sumed up as:
the datasource is recognised when I use my code as an application but not anymore if I use a servlet. I do not have a clue why... and how to make the servlet work... and I can not find any answer in the tutorials neither in the other releases.

Here a little more about it:
* I use a JDBC-ODBC diver: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
* I have created a datasource with the ODBC tool provided in the control Panel. (datasource called movie)
* I get a Connection to this database: dbConnection = DriverManager.getConnection("jdbc:odbc:movie", "myLogin", "myPassword");
* I create a new table only to test the success of the connection or not.

It works fine when in a application:
import java.sql.*;
public class CreateCoffeesApp {
public static void main(String args[]) {
[...]
My database is updated...

But when I use the servlet, a SQLExeption is thrown: SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
This exception is written in the log file of my servlet runner.

the only change in the code is using the init method of the servlet instead of the main:
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class CreateCoffeesServlet extends HttpServlet {
public void init() {
[...]

The driver seems to be found since the exception begins with [Microsoft][ODBC Driver Manager]... then I can not understand why the datasource is not recognized any more....

Please, help...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2002
Added on Dec 4 2001
3 comments
160 views