Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jsp error??

Status
Not open for further replies.

pdotd

Programmer
Jun 15, 2004
29
CA
when i run my jsp script i get this error:
exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:346)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
SchoolController.directTo(OfficeController.java:203)
SchoolController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.NullPointerException
bean.OfficeRegBean.getData(OfficeRegBean.java:179)
bean.OfficeRegBean.getEmployees(OfficeRegBean.java:141)
org.apache.jsp.employees_jsp._jspService(employees_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
OfficeController.directTo(OfficeController.java:203)
OfficeController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)



here is my OfficeRegBean on line 179

Statement mystatement = connection.createStatement();

and this is my method within line 179 that gets called

public ResultSet getEmployees()
{
try
{
query = "SELECT * FROM employees";


// Create the statement
Statement mystatement = connection.createStatement();

// Create the Resultset
return mystatement.executeQuery(query) ;
}
catch (SQLException sqle)
{
//System.out.println("err " + sqle.getMessage());
return null;
}


}

any solution to this errors would be great.

thanks

 
you are right...my connection object was not getting initialized.....

however after i fixed that problem, i got this another error msg posting:

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: No data found
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.employees_jsp._jspService(employees_jsp.java:130)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
OfficeController.directTo(OfficeController.java:203)
OfficeController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.sql.SQLException: No data found
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
org.apache.jsp.employees_jsp._jspService(employees_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
OfficeController.directTo(OfficeController.java:203)
OfficeController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

Here is my access connection code to the database in my Java Bean

package bean;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.*;

public class OfficeRegBean
{

private final String DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
private final String DBURL = "jdbc:eek:dbc:employeedb";
private final String UNAME = "";
private final String PASSWD = "";
private boolean trace = false;

private Connection connection;
private Statement statement;
private String query;
private ResultSet results;
private PrintWriter out;

//Bean contructor
public OfficeRegBean()
{
try
{
// Trace
if(trace)

DriverManager.setLogWriter(new PrintWriter(System.out));

// Load the driver
Class.forName(DRIVER);
connection = DriverManager.getConnection(DBURL,UNAME,PASSWD);
}

catch (ClassNotFoundException e)
{
System.out.println("Fail to load JDBC/ODBC driver" + e.getMessage());
}
}


** now i not sure if this could be a problem, but when i open up my DB file in access, i get a "Security Warning" saying:


"Opening 'C:\database\EmployeeDB.mdb'

This file may not be safe if it contains code that was intended to harm your computers."


any suggestions to what might fix this or these error(s)?


 
i have fix my connection problem to the database, but now when i run my jsp script i get this error posting:

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:346)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
OfficeController.directTo(OfficeController.java:203)
OfficeController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.NullPointerException
bean.OfficeRegBean.getData(OfficeRegBean.java:209)
bean.OfficeRegBean.getEmployees(OfficeRegBean.java:161)
org.apache.jsp.employees_jsp._jspService(employees_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
OfficeController.directTo(OfficeController.java:203)
OfficeController.doGet(OfficeController.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


now here is my getEmployees method:


public ResultSet getEmployees()
{
query = "SELECT * FROM employees";

return getData(query);
}

And here is my getData method:

public ResultSet getData(String query)
{
try
{

if (trace)
{
connectToDB();
}
// Create the statement
Statement mystatement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

// Create the Resultset
return mystatement.executeQuery(query) ;


}
catch (SQLException sqle)
{
//System.out.println("getData: " + sqle.getMessage());

return null;
}
}

any help would be greatly apprecaited to why i get this error or how it can be fixed

thanks
 
ok there we go,

on line 209 i had my createStatement was wrong..

i fixed it ..and it now works

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top