Hi ,
I am using jswdk1.0. I am trying a simple database connection inside the
jsp.
Please help!
Thanks
Saigeetha
I get the follwing error when my jsp is compiled.
IMPORTANT: Do not modify the generated servlets
JspEngine --> C:\jswdk-1.0-ea\examples\jsp\hellouser\hellouser.jsp
inside the name handler
after connecting to db
Unhandled error! You might want to consider having an error page to report
such
errors more gracefully
com.sun.jsp.JspException: Unknown exception:
javax.servlet.ServletException: Ca
nnot create bean of class hello.NameHandler
at
C_0003a.jswdk_0002d_00031_0005f_00030_0002dea.examples.jsp.hellouser.
hellouser_jsp_1._jspService(hellouser_jsp_1.java:120)
at com.sun.jsp.runtime.HttpJspBase.service(HttpJspBase.java:106)
at
com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
ava:80)
at
com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:180)
at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:219)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at
com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:154
)
at com.sun.web.core.Context.handleRequest(Context.java:412)
at com.sun.web.server.ConnectionHandler.run(Compiled Code)
I am not able to figure out what i am missing.
namehandler.java
package hello;
import java.sql.*;
import java.util.*;
import java.beans.*;
public class NameHandler {
String username;
Vector deptList_;
Connection con_;
public NameHandler() {
DBAccess db;
System.out.println("inside the name handler");
deptList_ = new Vector();
username = null;
try {
db = new DBAccess("sun.jdbc.odbc.JdbcOdbcDriver", "eus",
" ", " ");
Connection con = db.getConnection();
doQuery();
} catch (BCIException e) {
System.err.println(e.toString());
System.exit(1);
}
}
public Connection getConnection()
{
return con_;
}
public void setConnection(Connection con)
{
con_ = con;
}
public void setUsername( String name ) {
System.out.println("user name is"+name);
name = name.trim();
if (name.length() == 0)
username = "saigeetha";
else
username = name;
}
public Vector getDepartments()
{
return deptList_;
}
public void setDepartments(String dept)
{
deptList_.addElement(dept);
}
public void doQuery () {
String deptQuery = "SELECT DEPTID, DEPTNAME FROM DEPARTMENT";
try {
Statement s = con_.createStatement();
ResultSet rs = s.executeQuery (deptQuery);
while (rs.next()) {
System.out.println("the value of dept id is"+
rs.getInt(1));
deptList_.addElement(rs.getString(2));
}
}catch (SQLException e) {
System.out.println( "error occured in the query:"+
e.getMessage());
}
}
public String getUsername() {
System.out.println("inside the getter\n");
return username;
}
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html