• 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

resultset not give me result and not return data in my textbox

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sir I am use datasource and resultset with this code this code not give me error

Sir I use one button and one text box that name is m1 I try move resultset value into mt my textbox but resultnot give me data


My code


public String button1_action() {
Connection conn = null ;
Statement sqlStatement = null ;
ResultSet rs = null ;
try {
javax.naming.Context ctx = new javax.naming.InitialContext() ;
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Travel") ;
conn = ds.getConnection() ;
// setup the connection
conn.setAutoCommit(false) ;
// execute the query
sqlStatement = conn.createStatement() ;
rs = sqlStatement.executeQuery("select count(*) from TRIP" ) ;
rs.next() ;
int rows = rs.getInt(1) ;
m1.setValue(Integer.toString(rows));
conn.commit() ;
info("Rows in table TRIP: " + Integer.toString(rows)) ;
}

catch (Exception ex) {
error("Error counting rows: " + ex.getMessage() );
}
return null;
}


please give me idea how I get data in textbox form result
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you see any exceptions? If so, please post them. Also the code that you posted, is that part of a jsp/servlet or some standalone client? Providing more details about your application might help us in figuring out the issue.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic