Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unable to retrieve data from the db

 
Dinuka Arsakularatne
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic