It's not a secret anymore!*
The moose likes JDBC and the fly likes Problem in displaying result set value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in displaying result set value" Watch "Problem in displaying result set value" New topic
Author

Problem in displaying result set value

yogitad devarajan
Greenhorn

Joined: Oct 18, 2006
Posts: 8
Hi , I am reading an image from the database..I am trying to get value of a column from the database(here name is the column in the database )and display it..After String name= rset.getString(name); is executed the page is blank..but if I comment the line then the image and other details are displayed ..Could anyone tell me what the problem is..here is the code
while ( rset.next())
{

String name= rset.getString(name);
imageProxy = (OrdImage)rset.getORAData("image",OrdImage.getORADataFactory());
path = path + imagename;
imageProxy.getDataInFile(path);
conn1.commit();
out.println("<img src=\"" +path+ "\" align=left >");
out.println("<tr><td align=left>Type of the image " + imageProxy.getMimeType() + "</td></tr>");

}
Thanks
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by yogitad devarajan:

String name= rset.getString(name);


try to change the parameter name with rset.getString(column no) or change with rset.getString("name");
and print the String name after above line..
[ November 14, 2006: Message edited by: Saif uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You are using Oracle? Something to remember with Oracle is that if you write a query like this:

your results will be returned with uppercase column names.

If you write the query like this:

your results will be returned with lowercase column names.

Because of this, it is generally safer to specify the columns you want to return in your sql (since the column position is not guarenteed - a table still contains the same data regardless of which ordinal positions its columns have).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
yogitad devarajan
Greenhorn

Joined: Oct 18, 2006
Posts: 8
Hi ,
Thanks for the reply..I gave the column name in the select statement and it now works..
I am now trying to display 2 images with the same name ..The name that I have given is flower.jpg in the database..But when I execute the display is empty , however when I give different image names in the table it displays the image based the gievn name..Could anyone let me know if this is the right way to do it? .Here is the code..

String query = "select image,name from image_table where name='"+imagename+"'";
PreparedStatement pstmt = conn1.prepareStatement(query);
response.setContentType("image/jpeg");
String path="C:\\Yogita\\";
rset = (OracleResultSet)stmt.executeQuery(query);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Image Details</title>");
out.println("</head>");
out.println("<body>");
out.println("<left><h4>Image Details</h4></left>");
out.println("<table align =left >");
while ( rset.next())
{
name= rset.getString("name");
imageProxy = (OrdImage)rset.getORAData("image", OrdImage.getORADataFactory());
path = path + name;
imageProxy.getDataInFile(path);
conn1.commit();
out.println("<img src=\"" +path+ "\" align=left >");
out.println("<tr><td align=left>Name of the image " + name + "</td></tr>");
out.println("<tr><td align=left>Type of the image " + imageProxy.getMimeType() + "</td></tr>"); out.println("<tr><td align=left>Format of the image " + imageProxy.getFormat() + "</td></tr>");

}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in displaying result set value
 
Similar Threads
JSP Help Regarding the Radio Button
how to retrieve image in jsp page from a seperate folder.
Combo box problem in jsp
retrieving column caption in access
jasper compiler problem