Hello,
Are you getting any HTML output at all? Try to leave more messages to see
where it is breaking down.
Try
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ).newInstance();
This "newInstance()" is often necessary.
I don't use access so I don't know about the drivers or URL.
It looks like everything is there.
Good Luck,
Craig
-----Original Message-----
From: Bo Wang [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 17, 2001 8:15 PM
To: [EMAIL PROTECTED]
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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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.
>
>