You need to make a DNS entry.  The program I used to run my SQL looks like
this:
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;



public class ClearTypes3 extends HttpServlet {

    private Connection con = null;

      public void init(ServletConfig config) throws ServletException{
         super.init(config);
      try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             con = DriverManager.getConnection ( "jdbc:odbc:test_a");
                }
                catch (ClassNotFoundException e) {
                throw new UnavailableException(this,"Couldn't load database
driver");
          }

                catch(SQLException e) {
             throw new UnavailableException(this,"Couldn't get db
connection");
                }
            }

    public void doGet (HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {


      res.setContentType("text/html");

      PrintWriter out = res.getWriter();

          out.println("<HTML><HEAD><TITLE>Clearance Type
Codes</TITLE></HEAD>");
          out.println("<BODY>");

          HtmlSQLResult result =
            new HtmlSQLResult("SELECT [field1] as clear_type_code, [field2]
as
clear_type_name FROM clear_type_lkp",con);

          out.println("<H2>Clearance Types</H2>");
         out.println(result);
          out.println("</BODY></HTML>");

           }

   public void destroy() {
                   try {
                        if (con != null) con.close();
                     }
                     catch(SQLException ignored) { }
                }

}

(this was more or less taken from the Jason Hunter Java Servlet Programming
book.)


I didn't have to do anything to my servlets.properties file.


Ken Rowe
[EMAIL PROTECTED]

-----Original Message-----
From: [EMAIL PROTECTED] at X400PO
Sent: Tuesday, May 23, 2000 10:58 AM
To: [EMAIL PROTECTED] at X400PO
Subject: DB connection


Message authorized by:
    : [EMAIL PROTECTED] at X400PO

___________________________________________________________________________
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