Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SELECT COUNT

 
j deming
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I query an oracle database for a particular column count and then store the returned value as an int in my servlet?
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, take a look at the JDBC tutorial from sun at: http://java.sun.com/docs/books/tutorial/jdbc/index.html
there you�ll find wath you want.
 
shri ganesh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
assuming your column name is empno, the query would look like
Statement stmt = null;
ResultSet rs = null;
String strSql = "select count(empno) from emp";
rs = stmt.executeQuery(strSql);
int empCount = Integer.parseInt(rs.getString(1));
This should help!!
bye
shri
 
Sunetra Saha
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use the above code ,just make sure your resultset contains anything( rs.next()) before you try to get the string :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic