public void init( ServletConfig config )
You added a method init() with a void parameter list, which just gets added as a method to the servlet class, but does not correspond to the method declared in the Servlet interface.
So, change :
public void init() throws ServletException {
to:
public void init( ServletConfig cfg ) throws ServletException {
- Fernando
At 12:29 PM 2/9/00 -0800, you wrote:
Dear all,
Scenario:
Win98, Apache 1.3.11, JServ 1.1, JSDK2.0, Oracle JDBC(thin client) 8.1.6
Jserv is autoloaded by Apache.
Oracle DB (8.0.5) is across network (TCP) on Solaris.
Problem:
Can't get any connections to work in servlet.
Can't get any servlet messages in logs.
Tried the following:
In jserv.properties, added
- wrapper.classpath=c:\java\linux-dist\jars\JDBCclasses12.zip
In zone.properties, added
- repositories=c:\java\linux-dist\jars\JDBCclasses12.zip
In httpd.conf,
LogLevel debug
The servlet fails to connect somehow. No output was generated in Apache
and
JServ logs. Does not even logs System.err.println (purposely set this in
init()).
Browser only sees "hello" (based on program logic).
Output of http://localhost/servlets/DBTest :
hello
A java application (with main()) works fine (after setting
CLASSPATH=c:\java\linux-dist\jars\JDBCclasses12.zip;. in environment).
Output of "java SimpleSQL":
Result: LLTEST.WORLD
As far as servlet execution, SessionSnoop and IsItWorking works fine.
Tried the same set of programs on
RHat6.1, BlackdownJDK1.2.2P4, Apache 1.3.9, JServ 1.1, JSDK2.0, Oracle
JDBC(thin client) 8.1.6.
Again, only the SimpleSQL app works. No mesgs in Apache & JServ logs.
Thank you in advance for your assistance.
-DBTest.java code-----------------------------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class DBTest extends HttpServlet {
Connection dbCon;
public void init() throws ServletException {
/* Connect to the database */
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
dbCon = DriverManager.getConnection("jdbc:oracle:thin:@bluesky:1521:lltest",
"webtest","webtest");
} catch (ClassNotFoundException e) {
System.err.println("DBTest: Database Driver could not be found.");
System.err.println(e.toString());
} catch (SQLException e) {
System.err.println("DBTest: Error connecting to database.");
System.err.println(e.toString());
}
System.err.println("End of Init");
System.out.println("End of Init");
ServletContext sc = getServletContext();
sc.log("Init function");
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Statement stmt;
ResultSet rs;
res.setContentType("text/html");
PrintWriter out = res.getWriter();
/* Execute Query */
try {
if (dbCon != null) {
stmt = dbCon.createStatement();
rs = stmt.executeQuery("select * from global_name");
out.println("has value");
}
}
catch (SQLException e) {
res.sendError(res.SC_ACCEPTED, "The request has been accepted, but it failed to complete due to a problem querying the database.");
return;
}
out.println("hello");
}
}
=======================================
Fernando Salazar <[EMAIL PROTECTED]>
w -781-392-2514