aspose file tools*
The moose likes JDBC and the fly likes java.sql.SQLException: Before start of result set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: Before start of result set" Watch "java.sql.SQLException: Before start of result set" New topic
Author

java.sql.SQLException: Before start of result set

Rax Wer
Greenhorn

Joined: Mar 31, 2010
Posts: 12
Hello All,

I am creating a simple servlet, which is retrieving a value from the database. i am using eclipse IDE.

Here is the code.


Getting an error:



java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:692)
at com.mysql.jdbc.ResultSet.getStringInternal(ResultSet.java:5476)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:5420)
at Ex.doGet(Ex.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)


I do not understand, where i am wrong. Name of database, table, fileds are all right.
No typing error.

Please any help me with this thing.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
Have you called next() before using the ResultSet? Try this Java™ Tutorials Page for more details.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
Is the code throwing the Exception actually quoted here; it says at doGet but I can't seem to find doGet in your quoted code?
Rax Wer
Greenhorn

Joined: Mar 31, 2010
Posts: 12
Campbell Ritchie wrote:Is the code throwing the Exception actually quoted here; it says at doGet but I can't seem to find doGet in your quoted code?


Yes it is the same error, no doubt in that.
Rax Wer
Greenhorn

Joined: Mar 31, 2010
Posts: 12
Thanks for replying....

Campbell Ritchie wrote:Have you called next() before using the ResultSet? Try this Java™ Tutorials Page for more details.



I am a beginner to this, can you please write the thing you are actually suggesting. So that it can be Corrected properly..
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2477
    
    7

(As Campbell Ritchie says)

The exception hapended in Ex.doGet
You posted the code of Ex.doPost

[edit: mistyped name]


OCUP UML fundamental and ITIL foundation
youtube channel
Rax Wer
Greenhorn

Joined: Mar 31, 2010
Posts: 12
Hello Everyone..
I am not using doGet method at all. Posted the same code i sun and the error produced.. Thats why i am not getting the thing that if doPost is used there, why m getting

Error:
at Ex.doGet(Ex.java:39)

Also there no such errorneous code on line 39.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2477
    
    7

Can you check if the Ex class executed by your servlet container is compiled from the Ex class code that you show us?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: Before start of result set
 
Similar Threads
Web App cannot see Mysql data
Getting EXception
Secure Login through JAAS and servlet
result set not retrieved
Cannot insert data into table and throwing null message at Exception