• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to retrieve data from the db

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't seem to be moving though your ResultSet. I'd expect this sort of logic when using a ResultSet:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic