This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SELECT COUNT" Watch "SELECT COUNT" New topic


j deming

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:
there you�ll find wath you want.
shri ganesh

Joined: Jul 24, 2001
Posts: 4
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!!
Sunetra Saha
Ranch Hand

Joined: Feb 25, 2001
Posts: 77
If you use the above code ,just make sure your resultset contains anything( before you try to get the string :-)
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