Problem with executeQuery()

Hello all,

I've the following code in my JSP. I use Apache Tomcat 6.0 along with MySQL. Problem is i'm unable to execute the following query. The page goes to a wait that is the apache takes almost 99% of the CPU time and there by continues with displayin wither error or the page. I wonder that same code works for another table name "mcq" whose table description is same as that of table "physics_mcq". Plz help me out...... The code is....

rst=stmt.executeQuery("select max(no) from physics_mcq");

rst.next();

nt max=rst.getInt("max(no)");

With regards,

Kiran

[611 byte] By [kiranbedrea] at [2007-11-27 2:21:18]
# 1
Can you just try...rst=stmt.executeQuery("select max(no) as maxno from physics_mcq");rst.next();nt max=rst.getInt("maxno");
Noorula at 2007-7-12 2:23:48 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hey Noorul

Even the followin code doesnt work. But as i said before it works for other table name....

rst=stmt.executeQuery("select * from physics_mcq");

while(rst.next())

{

int t_qno=rst.getInt("no");

String t_ans=rst.getString("ans");

q_map[t_qno]=t_qno;

ans_list[t_qno]=t_ans;

}

kiranbedrea at 2007-7-12 2:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
can you perform this query from an SQL console?if not , then sounds like a DB issue, not an executeQuerry() issue...null
cafBeana at 2007-7-12 2:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Try int max = 0;rst=stmt.executeQuery("select max(no) as max_no from physics_mcq");if rst.next() max=rst.getInt("max_no");
tolmanka at 2007-7-12 2:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks to all who answered here... There was logical error in my code and it wasn't related with the executeQuery()..... My prob is solved.... :-)With regards,Kiran N Bedre
kiranbedrea at 2007-7-12 2:23:49 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...