----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

I am trying to retrieve info from an MS-Access database through a servlet
using JDBC-ODBC.  I have simple test servlets working ( that don't talk to a
db); I have a non-servlet Java class that can talk to the database.  When I
try essentially the same code in the Servlet, I get an access violation from
java.exe.  I don't find anything in the logs although perhaps I'm not
looking in all the right places.

NT4.0
jkd 1.2.2
jsdk2.0
apache 1.3.9
jserv 1.1

The "vanilla" java class that works:
----------------------------------------------------------------------------
----------
import java.sql.*;

public class Connect
{
  public static void main(String[] args)


    try
    {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      String sourceURL = "jdbc:odbc:technical_library";
      Connection dbCon = DriverManager.getConnection(sourceURL);
      Statement sql = dbCon.createStatement();

      ResultSet rs = sql.executeQuery("select lastname, firstname from
authors");

      while(rs.next())
      {
        System.out.println(rs.getString("lastname") + ", " +
rs.getString("firstname"));
        }
    }
    catch(ClassNotFoundException cnfe)
    {
      System.err.println(cnfe);
    }
    catch(SQLException sqle)
    {
      System.err.println(sqle);
    }
  }
}
----------------------------------------------------------------------------
-------
the servlet that does NOT work

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class test extends HttpServlet
{
  public void doGet(HttpServletRequest req, HttpServletResponse res)
                throws ServletException, IOException
  {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    out.println("Before try");

    try
    {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      String sourceURL = "jdbc:odbc:technical_library";
      Connection dbCon = DriverManager.getConnection(sourceURL);
      Statement sql = dbCon.createStatement();

      ResultSet rs = sql.executeQuery("select lastname, firstname from
authors");

      while(rs.next())
      {
//        System.out.println(rs.getString("lastname") + ", " +
rs.getString("firstname"));
        }
    }
    catch(ClassNotFoundException cnfe)
    {
//      System.err.println(cnfe);
    }
    catch(SQLException sqle)
    {
//      System.err.println(sqle);
    }

    out.println("<BR>After try");
    out.close();
  }
}



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to