Bhaskar Duvvuri

Greenhorn
+ Follow
since Nov 30, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bhaskar Duvvuri

First of all I aplogize if I inconvenienced you by sending a personal message. I just was replying to your earlier mail. Secondly, yes! I am the same person. I guess they didn't like my name, which is what I am called. Anyhow, I followed your suggestion and used the code you sent. The url is working (i.e. it takes me to the target page), but the value for id is not showing up. Here is the url:
http://localhost:9090/self/jsp/PlaceBid.jsp?ad="%20+%20iD%20+%20"
the value of ad is not showing. Yes! I can see all three records without a problem.
20 years ago
JSP
Here is my query in my jsp
dbconn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
sql = dbconn.prepareStatement("SELECT AdStore.AdId, " +
"AdStore.AdType, " +
"AdStore.AdDesc FROM AdStore " +
"WHERE (((AdStore.AdStatus)='" + activeStatus + "'))");
ResultSet rs = (ResultSet) sql.executeQuery();
int recnum = 0;
while(rs.next())
{
System.out.println("Got more rows\n");
recnum ++;
out.println("<tr>");
out.println("<font color=\"blue\" size =\"3\"></size></font>");
out.println("<td>" + rs.getInt(1) + "</td>");
out.println("<td>" + rs.getString(2) + "</td>");
out.println("<td>" + rs.getString(3) + "</td>");
out.println("<td><A HREF=?action=PlaceBid.jsp&ad=\" + rs.getInt(1) + \">Bid</A></td>");
System.out.println("The link is: \n" +
"<td><A HREF=?action=PlaceBid.jsp&ad=\" + rs.getInt(1) + ">Bid</A></td>");
}
Now I want to provide a link to another page with each of the records fetched, and send that id as part of my url to the new page. The funny thing is, if I simply assign as follows:
int ad1 = rs.getInt(1);
within the while loop, my query breaks off right after fetching the first row. Not only that, no matter what I do, if I assign the value of any of the fields fetched to any variables/do any formatting, the query stops after fetching only one record with a SQLState of Null (No data found). But the fact is I have 3 rows in my table. If I remove the line with HREF from abvoe code, I get to see all three rows. With the code (as copied in place), I see only one row.
I am sooooo desperate for help. Come on! Someone take pity on me.
20 years ago
JSP
Hi all! I just thought I can some attention from the experts with JSP if I start a new thread than keep adding to the previous one. Anyhow, enclosed is my jsp. I am at my wit's end trying to figure out what is going wrong. Anyhow, to describe, the while (rs.next()) loop gets me all records from my table fine. But, if I add the HTML tags(code) for displaying the same records using rs.getInt(1) etc., it results in the following error, AFTER fetching the 1st record:This is from my stdout.log. If I remove any kind of display html (I even tried it with adding the fetched records to an array, but with no luck) etc. results in the same error. Please please...please help!!
Here is the error from the STDOUT.log file:
Inside the ViewAds.jsp
Got more rows
Fetched record:
1Car1993 Mazda RX-5Speed-72K-New tires/battery.
*** SQLException caught ***
SQLState:
null
Message:
No data found
Vendor:
0
Here is my JSP:
<%@ page import="com.project.source.Ad" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="adStore" scope="application" class="com.project.source.AdStore"/>
<%
String base = (String) application.getAttribute("base");
%>
<HTML>
<HEAD>
<TITLE>View Ads</TITLE>
</HEAD>
<BODY>
<table width="97%" >
<tr>
<td colspan="2"><jsp:include page = "Top.jsp" flush="true"/></td>
</tr>
<tr>
<td width="39%" height="500"><jsp:include page= "left.jsp" flush="true"/> </td>
<td width="67%" valign="top"><div align="center"><font size="6">View Ad and Place Bids</font><br>
</div>
<table width="100%" height="61" border="1" align="center" bordercolor="#666666">
<tr bgcolor="#CCCCCC">
<td width="28%" height="30"><div align="center"><font color="#FFFFFF">Ad
Id</font></div></td>
<td width="33%"><div align="center"><font color="#FFFFFF">Item</font></div></td>
<td width="39%"><div align="center"><font color="#FFFFFF">Short Description</font></div></td>
<td width="40%"><div align="center"><font color="#FFFFFF">View Details</font></div></td>
</tr>
<%
System.out.println("Inside the ViewAds.jsp\n");
Connection dbconn;
PreparedStatement sql;
String activeStatus = "A";
ArrayList adArray = null;

String dbUrl = "jdbc dbc rojectdb";
String dbUserName = "";
String dbPassword = "";

int ad = 0;
String shortD = "";
String longD = "";

try
{
//loading the database jdbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try
{
dbconn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
sql = dbconn.prepareStatement("SELECT AdStore.AdId, " +
"AdStore.AdType, " +
"AdStore.AdDesc FROM AdStore " +
"WHERE (((AdStore.AdStatus)='" + activeStatus + "'))");
ResultSet rs = (ResultSet) sql.executeQuery();
int recnum = 0;
while(rs.next())
{
System.out.println("Got more rows\n");
recnum ++;
System.out.println("Fetched record: \n" +
rs.getInt(1) + rs.getString(2) + rs.getString(3) + "\n");
%>
<TR>
<TD><FONT FACE="Verdana" SIZE="3"><%=rs.getInt(1)%></FONT></TD>
</TR>
<%
}
System.out.println("Total recs: " + recnum + "\n");
System.out.println("The array has:\n" + adArray);
}
catch (SQLException ex) {
System.out.println("*** SQLException caught ***\n");
while (ex != null) {
System.out.println("SQLState: \n" + ex.getSQLState());
System.out.println("Message: \n" + ex.getMessage());
System.out.println("Vendor: \n" + ex.getErrorCode());
ex = ex.getNextException();
}
}
catch (java.lang.Exception ex) {
ex.printStackTrace();
}
}
catch (ClassNotFoundException e)
{
System.out.println(e.toString());
}
%>
</TABLE>
<tr>
<td><INPUT TYPE="HIDDEN" NAME="formName" VALUE="ViewAd">
</tr>
</table>
</BODY>
</HTML>
20 years ago
JSP
OK! The problem I found was with showing the returned records. For some reason with the formatting I used in the While loop is killing the result set from fetching the next row. What I am doing wrong? If I removed the formatting (starting with <TR> in the while (rs.next()) loop), then I see all records in stdout.log. Help??
20 years ago
JSP
Thank you very much for replying. The thing is that I tried all combinations of sql with the jsp and no matter what I do, it only returns one row (the first row). I tried "SELECT *" and the result is the same. Is this something to do with tomcat 4.1.29 on Windows 2000? Please...help!!!
20 years ago
JSP
Thanks! I just put that in as part of my debugging. Anyhow, I am running Tomcat on windows 2000. Is there anything from the settings of tomcat I need to worry about?
20 years ago
JSP
Hi all! I have a JSP which queries a table (Access db). This table has 3 records, but my jsp returns only one record (the first one only). I am using Tomcat 4-1-29. Needless to say I am a novice to tomcat and/or the jsp programming. Enclosed is my jsp code. The same query returns me all three rows if I use the Access query facility. I also downloaded a program from internet, which takes the sql as a parameter and spits out the results. Even that is showing 3 rows. What am I doing wrong? Please...please help!!! If I put the same thing in a db bean and call it via my jsp, nothing is returned. The error message says (1 record via jsp direct, zero records via the db bean) SQLState: Null. Message: No data found.
I am really desperate. Please help. Here is my JSP code:
System.out.println("Inside the ViewAds.jsp\n");
int ad=0;
Connection dbconn;
ResultSet rs;
PreparedStatement sql;
String dbUrl = "jdbc dbc rojectdb";
String dbUserName = "";
String dbPassword = "";

try
{
//loading the database jdbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try
{
dbconn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
sql = dbconn.prepareStatement("SELECT AdStore.AdId, AdStore.AdDate, " +
"AdStore.AdStatus, AdStore.AdType, " +
"AdStore.AdDesc, AdStore.AdPrice, AdStore.HighBid FROM AdStore " +
"WHERE (((AdStore.AdStatus)='A'))");
rs = sql.executeQuery();
int recnum = 0;
while(rs != null && rs.next())
{
if (rs != null)
{
System.out.println("Got more rows\n");
recnum ++;
}
%>
<tr bgcolor="#CCCCCC">
<td width="28%" height="30"><div align="center"><font color="#FFFFFF"><%=rs.getInt(1) %></font></div></td>
<td width="33%"><div align="center"><font color="#FFFFFF"><%=rs.getString(4) %></font></div></td>
<td width="39%"><div align="center"><font color="#FFFFFF"><%=rs.getString(5) %></font></div></td>
<td width="40%"><div align="center"><font color="#FFFFFF">
<A HREF="<%=base%>?action=PlaceBid=1%>">Bid on this Item</font></div></td>
</tr>
<%
System.out.println("Total recs: " + recnum + "\n");
System.out.println("Fetched row: " +
rs.getInt(1) + rs.getString(4) + rs.getString(5) + "\n");
}
}
catch (SQLException ex) {
System.out.println("*** SQLException caught ***\n");
while (ex != null) {
System.out.println("SQLState: \n" + ex.getSQLState());
System.out.println("Message: \n" + ex.getMessage());
System.out.println("Vendor: \n" + ex.getErrorCode());
ex = ex.getNextException();
}
}
catch (java.lang.Exception ex) {
ex.printStackTrace();
}
}
catch (ClassNotFoundException e)
{
System.out.println(e.toString());
}
%>
20 years ago
JSP