File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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