How to get the value of mysql Query.....

Hi Friends,

I am running this query thorugh JSP :

rst = stmt.executeQuery("select count(*) from information_schema.columns where table_name='countrylist';");

Here this query returns that how many columns the table countrylist have....

But My problem is How I can take this value in a variable for my further process.

ple help me out....

[375 byte] By [Ravijia] at [2007-11-26 16:31:30]
# 1

> Hi Friends,

> I am running this query thorugh JSP :

> rst = stmt.executeQuery("select count(*) from

> information_schema.columns where

> table_name='countrylist';");

First, consider using prepared statements, although it' snot much of a problem with this example.

Second, consider applying good application design by maintinging strict MVC and multi-tier separation. JSPs shouldn't even know that there's something like a database, and certainly not access one.

> Here this query returns that how many columns the

> table countrylist have....

> But My problem is How I can take this value in a

> variable for my further process.

> ple help me out....

You mean "how to use the result set"? Consider reading the API or at least using Google...

http://www.google.com/search?q=resultset+examples

CeciNEstPasUnProgrammeura at 2007-7-8 22:56:02 > top of Java-index,Java Essentials,Java Programming...
# 2

Hi CeciNEstPasUnProgrammeur,

Thanks for your valuable reply......but tell me in this example how i can get the integer value of query.....

I know how to use rst(ResultSet)...

Actually i have an application where i have to read data from database to excel file but i am stucking on column value. when i am giving hardcorded value for the column according to table it's working well but i don't want to do it..it should be dynamically.

so i want the integer value of that query....ple help me regarding this....

Ravijia at 2007-7-8 22:56:02 > top of Java-index,Java Essentials,Java Programming...
# 3
> Thanks for your valuable reply......but tell me in> this example how i can get the integer value of> query.....Use the result set. That's what it's there for.
CeciNEstPasUnProgrammeura at 2007-7-8 22:56:02 > top of Java-index,Java Essentials,Java Programming...
# 4
Ok, Thanks for your time.....I got the solution.
Ravijia at 2007-7-8 22:56:02 > top of Java-index,Java Essentials,Java Programming...