retrieving data from column + mysql + problem!!!

please see this code

con = JDBCUtil.getConnection();

System.out.println("Established a connection");

cstmt = con.prepareCall("{call GetPayloadCount()}");

System.out.println("Called SP");

rs=cstmt.executeQuery();

System.out.println("Executed SP");

System.out.println("Column Count = " + rs.findColumn("RowCount") +":" + rs.toString());

System.out.println("Retrieved " + rs.getString(1));

//rowCount=Integer.parseInt(rs.getString("RowCount"));

All the System.out.println works Column Count gives value 1

stil when i try to get the calue of that column

rs.getString(1)

its showing error.

i'm getting sick of this.

even complex storedprocedures executed without any problem and this simple thing is not working

my SP is GetPayloadCount()

CREATE PROCEDURE `GetPayloadCount`()

BEGIN

SELECT count(*) As RowCount FROM payload;

END

i even tried

rs.getString("RowCount")

still its not working

[1287 byte] By [xemaa] at [2007-10-3 9:41:15]
# 1
Did you call rs.next()? By default it points to the "before start" row, which will cause an error when you try to read from the resultset.
gimbal2a at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
a simple question is why do you need a stored procedure for a simple query?..
jgalacambraa at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
its always a good programming practice to use Stored procedures.
xemaa at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
we don't use stored procedures or any sql statement on our app.. we use ejbql.. but still a good practice
jgalacambraa at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
ohh god whats that...thts a new info to me...can u pls gimme more details on this
xemaa at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
> Did you call rs.next()? By default it points to the> "before start" row, which will cause an error when> you try to read from the resultset.sorry...i didn't do that.now it works..thanks
xemaa at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

> its always a good programming practice to use Stored

> procedures.

Actually its not ! [Unless mandated by your client]

Using stored procedures is more like being bound to a DB say Oracle. Think about situations when the client decides to drop off Oracle and rather go for open-source database like MySQL or PostgreSQL due to the huge license fee.

Then your code might require a huge change. Instead you might prefer to write the sqls in your EJB/EJBQl/Javabean for easy maintenance.

RohitKumara at 2007-7-15 4:57:20 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...