aspose file tools
The moose likes Servlets and the fly likes JSP and ODBC Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "JSP and ODBC" Watch "JSP and ODBC" New topic
Author

JSP and ODBC

Nirmala Devi
Greenhorn

Joined: Jul 31, 2001
Posts: 3
I am trying to execute a java program from JSP, which will return a ResultSet to JSP. I am getting the Class not found error.
Part of my JSP:
<%@ page contentType="text/xml" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="dbconnectbean" scope="page" class="DBConnectBean"/>
<%!
ResultSet rs=null;
ResultSetMetaData rsmd=null;
int count;
%>
<resultset>
<%
rs=dbconnectbean.getResult(); ----> ERROR IN THIS LINE
My Java program:
import java.util.*;
import java.sql.*;
import java.io.*;
import java.text.*;
public class DBConnectBean implements Serializable {
private Connection con = null;
private String url;
private String userLogin;
private String password;
private static final String empID = "EMP1002";
public ResultSet rs = null;
private Statement stmt = null;
private PrintWriter out = null;
private String SQL;
static {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (Exception e) {
System.out.println("Can't get the driver");
e.printStackTrace();
}
}
public DBConnectBean() {
url=null;
userLogin=null;
password=null;
SQL=null;
}
public ResultSet getResult() throws SQLException
{
try {
url="jdbc dbc:JSPTest";
userLogin="guest";
password="guest";
con = DriverManager.getConnectionurl,userLogin, password);
} catch (Exception e) { e.printStackTrace(); }
try {
SQL="select * from employee_mst;
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
} catch (Exception e) { out.println ("Exception " + e ; }
return rs;
}
}
The error is:
org.apache.jasper.JasperException: Unable to compile class for JSPD:\jakarta-tomcat-3.2.3\work\localhost_8080%2Fexamples\_0002fjsp_0002fxmldb_0002ejspxmldb_jsp_2.java:73: Class jsp.DBConnectBean not found.
DBConnectBean dbconnectbean = null;
Any help is appreciated.
Regds
Devi
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
You need to import whatever package your DBConnectBean class is in.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JSP and ODBC
 
Similar Threads
a mistake for bean
Problem in retrieving data and store it in string
Breaking doXXX methods down into smaller ones
Vector from bean to servlet?
Problem in getting the data from DB using servlets