my dog learned polymorphism*
The moose likes Servlets and the fly likes SELECT COUNT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SELECT COUNT" Watch "SELECT COUNT" New topic
Author

SELECT COUNT

j deming
Greenhorn

Joined: Jul 25, 2001
Posts: 3
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

Joined: Jan 06, 2001
Posts: 977
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

Joined: Jul 24, 2001
Posts: 4
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

Joined: Feb 25, 2001
Posts: 77
If you use the above code ,just make sure your resultset contains anything( rs.next()) before you try to get the string :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SELECT COUNT
 
Similar Threads
Javaranch members
Smokers on javaranch
What do you do when you get home?
lifetime of pageContext?
VAJ 3.5.4 WTE Tales of Woe