Hi Pradeep Roy,
I have tested ur code in my machine using Apache +
resin. It is working fine. The jspDbAccess.java file I
haven't changed (only the driver classes, user,
passwd) The jsp file I changed which I am pasting
below
<%@ page import="java.sql.*,java.io.*, java.lang.*" %>
<jsp:useBean id="dbConnect"
class="dws.dbAccess.jspDbAccess" scope="session">
<jsp:setProperty name="dbConnect" property="*" />
</jsp:useBean>
<%
out.println("<br>The connection to database is made");
String strQuery = "Select * from tdealermaster";
dbConnect.setResultset(strQuery);
ResultSet rs = dbConnect.getResultset();
out.println("<br>Got the ResultSet");
int i = 0;
out.println("<br>Going to display the data");
while(rs.next() && i<10) {
out.println("<br>"+i+" "+rs.getString(1)+"
"+rs.getString(2));
i++;
}
out.println("<br>Data is Displayed End");
%>
This code is working perfectly in my machine using
MSSQL 7.0 Compare and try to find the error.
Vivek Ojha
--- Pradeep Roy <[EMAIL PROTECTED]> wrote:
> Hi All
>
> I have tried to rewrite the Beans as suggested by
> Vivek. That is connection
> is established in the constructor.
>
> Please see my Bean and the corresponding JSP. Still
> it is giving problem.
> Problem is in the bold letter within the JSP page as
> below.
> In the JSP page...( for full jsp page see below)
>
> dbConnect.setResultset(query1);
> ResultSet rs=dbConnect.getResultset();
>
> ( when I am writting the above two the error is as
> follows :
> *** Error: "dbConnect" is either a misplaced package
> name or a non-existent
> entity.)
>
> OR
>
> dbAccess.jspDbAccess.setResultset(query1);
> ResultSet rs=dbAccess.jspDbAccess.getResultset();
>
> Please see the code and suggest. Plzzzzzzzzzzzzzz.
>
> Thanks & Regards
> Pradeep
>
> Beans:
>
> package dbAccess;
>
> import java.util.*;
> import java.sql.*;
> import java.lang.*;
> import java.io.*;
>
> public class jspDbAccess {
>
> String firmcode;
> String workid;
> String job;
> String costcode;
> Statement statement=null;
> Connection connection=null;
> ResultSet resultSet=null;
>
> //Constructor
>
> public jspDbAccess()
> {
> String
> driverName="com.ibm.as400.access.AS400JDBCDriver";
> String url="jdbc:as400://xxxx" ;
> String user="xxxx";
> String passwd="xxxxx";
>
> try
> {
> //loading the driver
> Class.forName(driverName);
> connection =
> DriverManager.getConnection(url, user, passwd);
> statement=connection.createStatement();
> System.out.println("connected");
> }
> // Error if fail to load the driver
> catch (Exception exp)
> {
> connection=null;
> System.out.println("Error occured at
> loading the Driver: "
> +exp);
> }
>
> }
>
>
> //
> public void setResultset(String sqlStr)
> {
>
> try
> {
>
> resultSet=statement.executeQuery(sqlStr);
> }
> catch (Exception exp)
> {
> System.out.println("Error occured at
> loading the Driver: "
> +exp);
> }
>
> }
>
> //
> public ResultSet getResultset()
> {
> return resultSet;
> }
>
>
> //
> public void setFirmcode(String firm)
> {
> if (firm != null )
> {
> firmcode=firm;
> }
> }
>
> //
> public void setWorkid(String id)
> {
> if (id != null )
> {
> workid=id;
> }
> }
>
> //
> public void setJob(String Jobname)
> {
> if (Jobname != null )
> {
> job=Jobname;
> }
> }
>
> //
> public void setCostcode(String code)
> {
> if (code != null )
> {
> costcode=code;
> }
> }
>
> //
> public void reset()
> {
>
> }
> }
>
> And the JSP is as follows:
>
>
> <%@ page import="java.sql.*,java.io.*, java.lang.*,
> javax.servlet.
> *,javax.servlet.http.*" %>
>
> <jsp:useBean id="dbConnect"
> class="dbAccess.jspDbAccess" scope="session">
> <jsp:setProperty name="dbConnect" property="*" />
> </jsp:useBean>
>
> <html>
> <head> <title>Puchase Order Enquiry</title> </head>
> <body text="White"
> bgcolor="#000000"
> leftmargin=0
> topmargin=0
> marginwidth=0
> marginheight=0>
>
> <hr align="left" width=19% size=2 color="White">
>
> <table width="175" border="0" cellspacing="0"
> cellpadding="0">
>
> <tr>
> <td valign="TOP">
> <img align="middle" src="jpLogo_3.gif"
> width=149 height=75
> border=0
> alt="Jobpac Logo"></td>
> </tr>
>
> </table>
>
> <hr align="left" width=19% size=2 color="White">
>
> <img align="middle" src="poEnquiry.gif" width=780
> height=16 border=0 alt
> ="Jobpac Logo">
>
> <% if ((request.getParameter( "Workid" ) !=
> null) &&
> (request.getParameter( "Job" ) != null) &&
> (request.getParameter( "Costcode" ) !=
> null) &&
> (request.getParameter( "Resultset" ) !=
> null)) { %>
>
> <%
> String firm = request.getParameter( "Workid"
> );
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail – Free email you can access from anywhere!
http://mail.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets