File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Mongo DB Applied Patterns
this week in the
MongoDB
forum
or a resume review from
Five Year Itch
in the
Jobs Discussion
forum!
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
Exception occurred in target VM: Invalid operation at current cursor position.
Kaustubh G Sharma
Ranch Hand
Joined: May 13, 2010
Posts: 1145
I like...
posted
May 30, 2012 06:23:09
0
Getting the mention exception while running below
servlet
code..
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import Beans.UserDetails; /** * * @author kaustubh.sharma */ public class ViewUSerDetails extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { UserDetails dt= new UserDetails(); try { HttpSession session = request.getSession(); String name=""; String age=""; String pic=""; Class.forName("org.apache.derby.jdbc.ClientDriver"); Connection con1=DriverManager.getConnection("jdbc:derby://localhost:1527/telephonebillingsystem","admin","adminadmin"); Statement st1 = con1.createStatement(); ResultSet rs1 = st1.executeQuery("SELECT * FROM userdetails WHERE name='kaustubh'"); name=rs1.getString(1); [color=red] /* Throwing exception at this place */ [/color] dt.setName(name); age=rs1.getString(2); dt.setAge(age); pic=rs1.getString(3); dt.setPic(pic); session.setAttribute("name",name); response.sendRedirect("ViewUserDetails.jsp"); } catch(Exception e) { System.out.println(e); } } }
No Kaustubh No Fun, Know Kaustubh Know Fun..
Kaustubh G Sharma
Ranch Hand
Joined: May 13, 2010
Posts: 1145
I like...
posted
May 30, 2012 06:23:44
0
Stack trace
>Exception occurred in target VM: Invalid operation at current cursor position. java.sql.SQLException: Invalid operation at current cursor position. at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source) at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source) at org.apache.derby.client.am.ResultSet.getString(Unknown Source) at com.ViewUSerDetails.doGet(ViewUSerDetails.java:44) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57) at com.sun.grizzly.ContextTask.run(ContextTask.java:69) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309) at java.lang.Thread.run(Thread.java:619) Caused by: org.apache.derby.client.am.SqlException: Invalid operation at current cursor position. at org.apache.derby.client.am.ResultSet.checkForValidCursorPosition(Unknown Source) at org.apache.derby.client.am.ResultSet.checkGetterPreconditions(Unknown Source) ... 28 more <
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
posted
May 30, 2012 06:49:51
0
You miss
rs1.next()
more or less at line 42
Bye,
Nicola
Nicola Garofalo
Ranch Hand
Joined: Apr 10, 2010
Posts: 308
posted
May 30, 2012 06:50:37
2
Nicola Garofalo wrote:
You miss
rs1.next()
more or less at line 42
or, better
if(rs1.next()){ //... }
Kaustubh G Sharma
Ranch Hand
Joined: May 13, 2010
Posts: 1145
I like...
posted
May 31, 2012 00:11:27
1
It worked that nicola
I agree. Here's the link:
http://zeroturnaround.com/jrebel/download
subject: Exception occurred in target VM: Invalid operation at current cursor position.
Similar Threads
problem while reading data from excel sheet
resultset problem
problem with retrieving data
Trying to grab the last record.
Null Pointer Exception
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter