• 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

HELP -- Counting rows with oracle & jdbc

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following code snippet:
String queryJoinCount = "select count(contract_type_id) from clause_type_join where clause_id = ? and comment_id = ?";
PreparedStatement stmt = conn.prepareStatement(queryJoinCount);
stmt.setInt(1, clause.getId());
stmt.setInt(2, comment.getId());
ResultSet rs_count = stmt.executeQuery();
if(rs.next()){
//then some results were returned
int count = rs.getInt("count(contract_type_id)"); //problem here
}
I keep getting an sql exception on the line inside the if statement.
How do I refer to the column name that Oracle's count mechanism is returning?
thanks,
Erni
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you name the the count field like
select count(emp_id) emp_cnt from....
emp_cnt is now the field name
Dan
 
erin_az
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is helpful to know, thanks,
e.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic