hi try this code... i will work...
other wise don't do fully 1st try to connect with DB and execute the query
like that...
if not getting mail me at [EMAIL PROTECTED]




>package dbAccess;
>
>import java.util.*;
>import java.sql.*;
>import java.lang.*;
>import java.io.*;
>
>public class jspDbAccess {
>
         ResultSet resultSet=null;
>        public ResultSet setSql(String sqlStr)
>         {
>          Statement statement=null;
>          Connection connection=null;
>         String driverName="com.ibm.as400.access.AS400JDBCDriver";
>         String url="jdbc:as400://saturn" ;
>         String user="xxxx";
>         String passwd="xxxx";
>
>
>
>// Data to connect to database
>
>         try
>         {
>         //loading the driver
>             Class.forName(driverName);
>             connection = DriverManager.getConnection(url, user, passwd);
           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);
>         }
>
>
>        try
>         {
>             statement=connection.createStatement();
>             resultSet=statement.executeQuery(sqlStr);

>         }
>         catch (Exception exp)
>         {
>             System.out.println("Error occured at loading the Driver: "
>+exp);
>         }
>             return resultSet;

>         }
>
>
>
>
>               }
>
>
>My 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="*" />
>
>
><html>
><head> <titleEnquiry</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="Logo_3.gif" width=149 height=75 border=0
>         alt="Logo"></td>
>  </tr>
>
></table>
>
><hr align="left" width=19% size=2 color="White">
>
><img align="middle" src="enquiry.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( "Sql" ) != null)) { %>
>
><%
>         String firm = request.getParameter( "Workid" );
>         String jobname = request.getParameter( "Job" );
>         String cstcode = request.getParameter( "Costcode" );
>         String sqlStr = request.getParameter( "Sql" );
>
>         String costcodeName="";
>         String jobDescript="";
>
>String query1="SELECT OIORDN, OIITEM, OIDESC, OIQORD, OIUNIT, OIGUPR2,
>OITVAL from jp521dtai.jpordoi1 WHERE OIFMCD = '" + firm + "' AND OIJOB = '"
>+ jobname + "' AND OICODE = '" + cstcode + "'" ;
>
>ResultSet rs=dbConnect.setSql(query1);

>
>
>

>         try
>         {
>%>
><hr align="Left" Color="#ffffff" Size="1">
>
><TABLE border="0" cellspacing="0" cellpadding="0">
>
>   <tr>
>
>     <td align="right"><b>Job:</b>&nbsp;&nbsp;</td>
>     <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000"> <b>
><%=jobname%></b></FONT></td>
>     <td align="right">&nbsp;</td>
>     <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000">&nbsp;&nbsp; <b>
><%=jobDescript%></b></FONT></td>
>   </tr>
>   <tr>
>     <td align="right"><b>Cost Code:</b>&nbsp;&nbsp;</td>
>     <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000"> <b>
><%=cstcode%></b></FONT></td>
>     <td align="right">&nbsp;</td>
>     <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000">&nbsp;&nbsp; <b>
><%=costcodeName%></b></FONT></td>
>   </tr>
>
></TABLE>
>
>
>
><hr align="Left" Color="#ffffff" Size="1">
><P>
><TABLE WIDTH=100% BORDER=1 cellspacing=0 cellpadding=0>
>         <TR>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE="2">ORDER
>NO</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE
>="2">ITEM</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE
>="2">DESCRIPTION</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE
>="2">QUANTITY</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE="2">UNIT OF
>MEASURE</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE
>="2">RATE</FONT></td>
>         <td BGCOLOR="#000000"><FONT COLOR="#FFFFFF" SIZE
>="2">AMOUNT</FONT></td>
>         </TR>
>         <TR>
>
>         <%
>         while(rs.next()) {
>         %>
>         <TR>
>         <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000" SIZE="2">
><%=rs.getObject(1) %>  </td>
>         <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000" SIZE="2">
><%=rs.getObject(2) %>  </td>
>         <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000" SIZE="2">
><%=rs.getObject(3) %>  </td>
>         <td Align="RIght" BGCOLOR="#FFFFFF"><FONT COLOR="#000000"
>SIZE="2">
><%=rs.getObject(4) %>  </td>
>         <td BGCOLOR="#FFFFFF"><FONT COLOR="#000000" SIZE="2">
><%=rs.getObject(5) %>  </td>
>         <td Align="RIght" BGCOLOR="#FFFFFF"><FONT COLOR="#000000"
>SIZE="2">
><%=rs.getObject(6) %>  </td>
>         <td Align="RIght" BGCOLOR="#FFFFFF"><FONT COLOR="#000000"
>SIZE="2">
><%=rs.getObject(7) %>  </td>
>         </TR>
>         <% } %>
>
></TABLE>
>
><%
>         }
>         catch (Exception exp)
>           {
>             out.print("Error at data Processing. Please Try Again.");
>         }
>%>
>
>
>
>
>
><% } else { %>
>
><%
>         String id;
>         String firm;
>         String job;
>         String jobDescript;
>         String costcode;
>         String costcodeDescript;
>         String dataLibrary;
>
>String query0="SELECT WIWINO, WIMNAM, WIKM1, WIKM2, WIKM2 from r51ACTL.
>@WKIDWIP" ;
>
>%>
>
>-----
>----- here I have hard code the database connection & resultset accessing
>HERE which is giving the Result Set Correctly
>-----
>-----
>          <%
>         try
>         {
            rs=dbConnect.setSql(query0);

>%>
>
>
>
><FORM NAME='login'METHOD=get>
>
><TABLE border="0" cellspacing="0" cellpadding="0">
><tr>
>      <td align="right">Workid&nbsp;&nbsp;</td>
>      <td><select name="id" size="1">
>
>         <%
>         while(rs.next()) {
>         %>
>
>         <option value="<%=rs.getObject(1) %>"> <%=rs.getObject(1) %>
>         <% }
>         }
>         catch (Exception exp)
>           {
>             out.print("Error at data Processing. Please Try Again.");
>         }
>         %>
>         </select>
>      </td>
>   </tr>
>
>
>   <tr>
>     <td align="right">Firm&nbsp;&nbsp;</td>
>     <td><input type="TEXT" name="Workid"  size="2"></td>
>   </tr>
>
>   <tr>
>     <td align="right">Job&nbsp;&nbsp;</td>
>     <td><input type="TEXT" name="Job" size="10"></td>
>   </tr>
>   <tr>
>     <td align="right">Cost Code&nbsp;&nbsp;</td>
>     <td><input type="TEXT" name="Costcode" size="10"></td>
>   </tr>
>   <tr>
>     <td><input type="HIDDEN" name="Sql" value="SELECT WIWINO, WIMNAM,
>WIKM1, WIKM2, WIKM2 from r51ACTL.@WKIDWIP" ></td>
>   </tr>
>   <tr>
>     <td align="Left"></td>
>     <td align="right">
>         <input type="SUBMIT" value="  Start Query  ">
>             <input type="RESET" value="Clear"></td>
>   </tr>
></TABLE>
></FORM>
><hr align="Left" Color="White" Size="1">
>
>
>
>
>Please enter the values & press 'Start Query'...press 'Clear' for new
>entry.
>
>
>
>
><% } %>
>
>
></BODY>
></HTML>
>
>===========================================================================
>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
>
>===========================================================================
>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

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.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

Reply via email to