It's not a secret anymore!
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "unable to retrieve data from the db" Watch "unable to retrieve data from the db" New topic

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;
rset=stmt.excuteQuery("select * from TRAVEL.CARRENTAL");
<%= rset.getString("TRIPID")) %>

<% }
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

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:
subject: unable to retrieve data from the db
jQuery in Action, 3rd edition