How about, since you were already able to get the Java class to work, leave all your 
database functionality in that class, and simply instantiate that from your servlet. 
The servlet doesn't need to know any of the details about connecting to the database. 
Just pass the needed information for the query to the data access class, let it 
connect and execute the query, and return an array (or some other data structure) back 
to the servlet for display.

Keeping your data access in a separate layer is better design anyway. :-)

Liz
[EMAIL PROTECTED]
http://www.gymell.com

"A mailing list for discussion about Sun Microsystem's Java              Servlet API 
Technology." <[EMAIL PROTECTED]> wrote:
> Hi,

I have encountered a problem when attempting to connect to a MS Access
database hosted on an NT Server running JRun using a servlet. I have created
an ODBC datasource for the Access database on the NT server.

I first used a simple Java program to connect to the database and output
some records from a table. It executed successfully.

I then used the identical code in a simple servlet. The code snippet for
connecting to the database is as follows:

     // The name of the JDBC driver to use
     String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";

     // The JDBC connection URL
     String connectionURL = "jdbc:odbc:MyAccessDataSource";

     try {

        // Create an instance of the JDBC driver so that it has
        // a chance to register itself
        Class.forName(driverName).newInstance();

        // Create a new database connection.
        con = DriverManager.getConnection(connectionURL);

        ...

At this point in the execution, I get the following error message:

Exception! java.sql.SQLException: [Microsoft][ODBC Microsoft Access
Driver]General error Unable to open registry key 'DriverId'. at
sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code) at
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:4246) at
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1136) at
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:148) at
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:167) at
java.sql.DriverManager.getConnection(Compiled Code) at
java.sql.DriverManager.getConnection(DriverManager.java:159) at
EmployeeList.query(EmployeeList.java:148) at
EmployeeList.doGet(EmployeeList.java:66) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:516) at
javax.servlet.http.HttpServlet.service(Compiled Code) at
com.livesoftware.jrun.JRun.runServlet(Compiled Code) at
com.livesoftware.jrun.JRunGeneric.handleConnection(Compiled Code) at
com.livesoftware.jrun.JRunGeneric.handleProxyConnection(Compiled Code) at
com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(Compiled
Code) at com.livesoftware.jrun.service.ThreadConfigHandler.run(Compiled
Code)


Any help/insights would be appreciated,

Brian
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to