Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JRUN 3.0, JSP and the #@$#%&*! NullPointerException-- pls help.

843835Dec 15 2002 — edited Dec 16 2002
Hi guys

Let me put this one litely....

....HEEELLLPPPP....UUURRRRGGGEEEENNNTTT... AHHHHHHH!!!!

OK... That went nicely.. ;>
The problen is Im using JRUN 3.0 as a stand alone web server and Im accessing a Foxpro database. Unfortunately, i've run into the dreaded NullPointerException error. Please, can anyone help me with this? Another problem for me is that im on a tight sched and this is really getting into my nerves (does it show?). I admit, Im a newbie with JSP, but using JSP is so tempting. Here's a sample of the JSP file...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
<%@ page import="java.sql.*" %>

<%! Connection conn;
PreparedStatement stmt;
%>
<%! public void jspInit(){
try{
String sql = "SELECT * FROM password where " +
"(LOWER(Username) LIKE ? ";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection
("jdbc:odbc:;DRIVER=Microsoft FoxPro VFP Driver (*.dbf);"+
"UID=;"+
"Deleted=Yes;"+
"Null=Yes;"+
"Collate=Machine;"+
"BackgroundFetch=Yes;"+
"Exclusive=No;"+
"SourceType=DBF;"+
"SourceDB=database\\");
stmt = conn.prepareStatement(sql);
}catch(SQLException e){}
catch(ClassNotFoundException e){}
}
%>
<%! public void jspDestroy(){
try{
stmt.close();
conn.close();
}catch(SQLException e){}
}
%>
<HTML>
<BODY BGCOLOR="white">
<% String searchVar = ""; %>
<FORM ACTION="<%=request.getRequestURI() %>" METHOD="GET">
<INPUT TYPE="text" name="query" size="15" MAXLENGTH="30"
VALUE="<% if (request.getParameter("query") != null)
out.print(request.getParameter("query")); %>" %>
<INPUT TYPE="submit" VALUE="Search">
</FORM>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0">
<TR><TD><B>User Name</B></TD>
<TD><B>Password</B></TD></TR>
<%
if (request.getParameter("query") != null) {
String query = request.getParameter("query").toLowerCase();
stmt.setString(1, "%" + searchVar + "%");
ResultSet rset = stmt.executeQuery();

while (rset.next()){
%>
<TR><TD><%= rset.getString("username") %>
</TD><TD><%= rset.getString("password") %>
</TD></TR>
<%
}
}
%>
</TABLE>
</BODY>
</HTML>

And heres the error generated...
500 Internal Server Error
<PRE> <B>/pinoyinc/dbftest.jsp:</B> null java.lang.NullPointerException at jrun__dbftest2ejspc._jspService(jrun__dbftest2ejspc.java:50) at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1024) at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:936) at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34) at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:177) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1024) at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:936) at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:88) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1163) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1153) at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330) at allaire.jrun.http.WebEndpoint.run(WebEndpoint.java:107) at allaire.jrun.ThreadPool.run(ThreadPool.java:272)


Its basically simple. Sometimes it work, but most of the time it DOSNT! Please, if anyone out there has a solution, help end this suffering. You may email me at caloizky@yahoo.com. Advance thanks to all and more power to JAVA. Merry Xmas.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 13 2003
Added on Dec 15 2002
3 comments
170 views