tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jake Chin" <jacob...@earthlink.net>
Subject Re: JDBC question
Date Wed, 18 Apr 2001 21:49:39 GMT
I believe that's supposed to be doGet.

-----Original Message-----
From: Jann VanOver <Jann.VanOver@loudeye.com>
To: 'tomcat-user@jakarta.apache.org' <tomcat-user@jakarta.apache.org>
Date: Wednesday, April 18, 2001 2:40 PM
Subject: RE: JDBC question


>is that one method really named "deGet" ??
>
>-----Original Message-----
>From: Bo Wang [mailto:bowang3@home.com]
>Sent: Tuesday, April 17, 2001 8:15 PM
>To: tomcat-user@jakarta.apache.org
>Subject: Re: JDBC question
>
>
>Thanks for your help, here attached my servlet.
>I'm using win98 with Access 97, and set up a system DSN "Northwind" without
>userID and password.
>After I run this servlet, I got NullPointException.
>
>import java.io.*;
>import java.sql.*;
>import javax.servlet.*;
>import javax.servlet.http.*;
>
>public class JDBCServlet extends HttpServlet
>{
>    Connection dbConn;
>
>    public void init ( ServletConfig config ) throws ServletException
>    {
>        super.init( config );
>
>        try
>        {
>            Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
>            dbConn = DriverManager.getConnection( "jdbc:odbc:Northwind" );
>        }
>        catch ( ClassNotFoundException e )
>        {
>            System.out.println( "*****JDBC-ODBC bridge not found" );
>            return;
>        }
>        catch ( SQLException e )
>        {
>            System.out.println( "*****SQL exception thrown in init" );
>            return;
>        }
>    }
>
>    public void deGet( HttpServletRequest req, HttpServletResponse resp )
>                            throws ServletException, IOException
>    {
>        try
>        {
>            resp.setContentType( "text/html" );
>            PrintWriter out = resp.getWriter();
>
>            Statement stat = dbConn.createStatement();
>            ResultSet customers = stat.executeQuery( "select CustomerID,
>CompanyName, City, Country from " + "Customers" );
>
>            out.println( "<html>" );
>            out.println( "<head><title>Customer List</title></head>"
);
>            out.println( "<body>" );
>            out.println( "<h2>Customer List</h2>" );
>            out.println( "<table border=1>" );
>            out.println( "<tr><th>Customer ID</th>" );
>            out.println( "<th>Company Name</th>" );
>            out.println( "<th>City</th>" );
>            out.println( "<th>Country</th></tr>" );
>
>            while ( customers.next() )
>            {
>                out.println( "<tr>" );
>                out.println( "<td>" + customers.getString( "CustomerID" ) +
>"</td>" );
>                out.println( "<td>" + customers.getString( "CompanyName" )
+
>"</td>" );
>                out.println( "<td>" + customers.getString( "City" ) +
>"</td>" );
>                out.println( "<td>" + customers.getString( "Country" ) +
>"</td>" );
>                out.println( "</tr>" );
>            }
>
>            out.println( "</table>" );
>            out.println( "</body></html>" );
>
>            customers.close();
>            stat.close();
>            dbConn.close();
>        }
>        catch ( Exception e )
>        {
>            e.printStackTrace();
>        }
>    }
>}
>
>
>----- Original Message -----
>From: "RameshBabu R Muthuvel" <rmrameshbabu@hotmail.com>
>To: <tomcat-user@jakarta.apache.org>
>Sent: Tuesday, April 17, 2001 12:25 PM
>Subject: Re: JDBC question
>
>
>> Hi
>> There are numerous issues.
>>
>> Some are:
>> 1) either ur dsn is not there
>> 2) Your tables datatype doesn't match with the value passed or accessed
>from
>> servlet etc...........
>>
>> send ur servlet, to find out what really happens
>>
>> ramesh
>>
>> _________________________________________________________________________
>> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>>
>>


Mime
View raw message