File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQL Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQL Exception" Watch "SQL Exception" New topic

SQL Exception

chetan dhumane
Ranch Hand

Joined: Jan 07, 2009
Posts: 641

I get exception while executing following query

My code runs perfectly If I execute only first query.
I also checked for datatypes matching and table formats.

at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.ResultSetImpl.checkRowPos(
at com.mysql.jdbc.ResultSetImpl.getInt(
at org.apache.jsp.jsp.ShowAvailable_jsp._jspService(
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServletWrapper.service(
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
SQL Error

Author @
Moody blogger who do not like to behave like target setting machines work.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

You need to call before calling resultset.getInt(12).

Also, if you only use that one field, why use "select *"? You could write a more specific query.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489

chetan dhumane wrote:I get exception while executing following query
ResultSet resultset = statement.executeQuery("select * from db_finalreal where cost >=" + minValue + " and cost <= " + maxValue + " and city='"+ city + "'" + " and type='"+ type+"'");
agentid = 1;
agentid = resultset.getInt(12);
agentresultset=agentstatement.executeQuery("select * from db_finalagents where id="+agentid);[/code]

please make sure your SQL statement .

i think your problem is, you put a space after "and cost <= " :
so please use the following ResultSet SQL :
ResultSet rs = statement.executeQuery("select * from db_finalreal where cost >=" + minValue + " and cost <="
+ maxValue + " and city='"+ city + "' and type='"+ type+"'");

and write :;

Sorry my english isn't too good

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
I agree. Here's the link:
subject: SQL Exception
It's not a secret anymore!