Hi,
I get a strange message when I run the following Servlet.
I am wondering how the same Servlet works fine in Win95, but not in NT.
Please help me.
The message in the Web-server:
-----------------------------
JDBCServlet: init
java102.sql.SQLException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data
source name not found and no default driver specified
Servlet response:
-----------------
Error: 500
Internal Servlet Error:
java.lang.NullPointerException:
at JDBCServlet.doGet(JDBCServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:715)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:140)
at com.sun.web.core.Context.handleRequest(Context.java:375)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:135)
The source:
-----------
import java102.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class JDBCServlet extends HttpServlet
{
private Connection conn;
public void init(ServletConfig conf) throws ServletException
{
super.init(conf);
try
{
Class.forName("java102.sql.DriverSJ").newInstance();
conn =
DriverManager.getConnection("jdbc:socket://localhost:5588/jdbc:odbc:Tcp-loopback",
"scott","tiger");
}
catch (ClassNotFoundException cnfe)
{
System.out.println(cnfe.getMessage());
}
catch (SQLException sqle)
{
System.out.println(sqle);
}
catch(InstantiationException ine)
{
System.out.println(ine);
}
catch(IllegalAccessException iae)
{
System.out.println(iae);
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException
{
int updresult;
res.setContentType("text/html");
req.getServerName();
try
{
ServletOutputStream out = res.getOutputStream();
out.println("<html>");
out.println("<head>");
out.println("<title> JBDC Servlet </title>");
out.println("</head>");
out.println("<body>");
Statement stmt = conn.createStatement();
updresult = stmt.executeUpdate("update emp set ename = 'XXXXX' where ename =
'VIJAY'");
out.println("Row updated: " + updresult);
out.println("</body>");
out.println("</html>");
}
catch (SQLException sqle)
{
System.out.println(sqle);
}
catch (IOException ioe)
{
System.out.println(ioe);
}
}
public void destroy()
{
try
{
conn.close();
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
}
}
Additional info:
----------------
(Line No: 53) Statement stmt = conn.createStatement();
JSDK2.1/JDK1.2.2/WinNT/Netscape4.61/JDBC-ODBC Driver
Note:
-----
The same program works fine in Win95 with same JDBC Driver and Web Server.
Thank you.
___________________________________________________________________________
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