• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in displaying result set value

 
yogitad devarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
yogitad devarajan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>");

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic