can't know why SQLException
Hi ...
in one of my methods there's this query executing...
the query is executed perfectly, but whenever i want to check if the result set coming from it, if it's null or not, i get SQLException,, i have the same problem in another method...
here's a snap of the method..
ResultSet resultSet2 = statement.executeQuery(
"SELECT TimeIn1 FROM TimeLog WHERE LateDate='"
+ currentDate +"' AND empno="+ empno +";");
System.out.println("AFTER QUERY");
if(resultSet2.getDate(1) !=null){
System.out.println("SECOND TIME IN");
return SECOND_TIME_IN;
}
well ,, the sentence AFTER QUERY is printed..
the problem is in the conditionif(resultSet2.getDate(1) !=null)
wonder if any body know the reason...
# 1
I think you must position the cursor row,
ResultSet resultSet2 = statement.executeQuery(
"SELECT TimeIn1 FROM TimeLog WHERE LateDate='"
+ currentDate +"' AND empno="+ empno +";");
System.out.println("AFTER QUERY");
while(resultSet2.next()){
if(resultSet2.getDate(1) != null){
System.out.println("SECOND TIME IN");
return SECOND_TIME_IN;
}
}
# 4
07/07/25 18:24:36 java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid operation for the current cursor position.
07/07/25 18:24:36 at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
07/07/25 18:24:36 at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
07/07/25 18:24:36 at com.microsoft.jdbc.base.BaseResultSet.validateCursorPosition(Unknown Source)
07/07/25 18:24:36 at com.microsoft.jdbc.base.BaseResultSet.getDate(Unknown Source)
07/07/25 18:24:36 at TimeInProcess.determineFirstOrSecondTimeIn(TimeInProcess.java:109)
07/07/25 18:24:36 at TimeInProcess.recordTimeIn(TimeInProcess.java:36)
07/07/25 18:24:36 at EmployeeRecord.doPost(EmployeeRecord.java:38)
07/07/25 18:24:36 at EmployeeRecord.doGet(EmployeeRecord.java:29)
07/07/25 18:24:36 at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
07/07/25 18:24:36 at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:846)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:397)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:291)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:48)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:226)
07/07/25 18:24:36 at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:274)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:230)
07/07/25 18:24:36 at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
07/07/25 18:24:36 at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
07/07/25 18:24:36 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
07/07/25 18:24:36 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
07/07/25 18:24:36 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
07/07/25 18:24:36 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:846)
07/07/25 18:24:36 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:397)
07/07/25 18:24:36 at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
07/07/25 18:24:36 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451)
07/07/25 18:24:36 at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218)
07/07/25 18:24:36 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:119)
07/07/25 18:24:36 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
07/07/25 18:24:36 at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:245)
07/07/25 18:24:36 at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:231)
07/07/25 18:24:36 at oracle.oc4j.network.ServerSocketAcceptHandler.access$1000(ServerSocketAcceptHandler.java:33)
07/07/25 18:24:36 at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:820)
07/07/25 18:24:36 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
07/07/25 18:24:36 at java.lang.Thread.run(Thread.java:595)
# 7
> no need for it... because it's only record to be
> retrived with the same date and the same number..
> so i guess it's not the problem...
This is not the first time that I see your ignorance on the answers and behaving like Mr. know-it-all-better. Try to work on that.
JDBC tutorials are available here:
http://java.sun.com/docs/books/tutorial/jdbc/basics/index.html
ResultSet is explained here: http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
java.sql API documentation is available here:
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/package-summary.html
ResultSet API: http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html
By the way, Googling on the exact message had given you meaningful results:
http://www.google.com/search?q=%22Invalid+operation+for+the+current+cursor+position.%22