aspose file tools*
The moose likes JDBC and the fly likes unable to retrieve data from the db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "unable to retrieve data from the db" Watch "unable to retrieve data from the db" New topic
Author

unable to retrieve data from the db

Dinuka Arsakularatne
Ranch Hand

Joined: Aug 12, 2006
Posts: 198
hi all,

im new to jdbc and tried my first app using netbeans 5.5. my db is apache derby. i have correctly set up the driver and populated some tables. but when i write the neccessary code in my jsp to retrieve information through the DB no data is being displyed. following is my jsp code
<% InitialContext context = new InitialContext();
DataSource dataSource=(DataSource)context.lookup("java:comp/env/jdbc/DataSourceExample");
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try{
conn=dataSource.getConnection();
stmt=conn.createStatement();
rset=stmt.excuteQuery("select * from TRAVEL.CARRENTAL");
%>
<%= rset.getString("TRIPID")) %>
//rset.getString("NAME");
//rset.getString("DESCRIPTION");
//rset.getString("LASTUPDATED");

<% }
catch(SQLException e){}%>
<% finally{
if(rset !=null){rset.close();}
if(stmt !=null){stmt.close();}
if(conn !=null){conn.close();}
if(context !=null){context.close();}
}

}%>

can some one please point out to me as to what im doing wrong?

thank you in advance


if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You don't seem to be moving though your ResultSet. I'd expect this sort of logic when using a ResultSet:


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unable to retrieve data from the db