Thread: updateString error in PostgreSQL7.4 with JDBC

updateString error in PostgreSQL7.4 with JDBC

From
Suha Onay
Date:
Hi,
I have a problem with PostgreSQL 7.4. (With the old one 7.3 no probllem.)

I create a connection and a statement :
        Class.forName("org.postgresql.Driver");
        conn = DriverManager.getConnection(
                        O_Constants.DB_CONNECTION_URL,
                        O_Constants.DB_CONNECTION_USERNAME,
                        O_Constants.DB_CONNECTION_PASSWORD);
        st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
        rs = st.executeQuery("select * ...";

Then:
    rs.updateString(20 , ...);

The error is:
org.postgresql.util.PSQLException: Cannot update the result set because
it is either before the start or after the end of the results.
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateValue(AbstractJdbc2ResultSet.java:1595)
        at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateString(AbstractJdbc2ResultSet.java:1193)
        at admin.ValidationRequest.doGet(ValidationRequest.java:43)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
        at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:324)
        at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:395)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
        at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
        at
org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
        at java.lang.Thread.run(Thread.java:536)

The JDBC is:
    pg74.215.jdbc3.jar

If you have any comments, please help.
Thanks...


Re: updateString error in PostgreSQL7.4 with JDBC

From
Suha Onay
Date:
It is ok. I fetch the row with no problem.
The error is only in update types like updateString , updateRow,
updateInt...

ps.You are right JDBC list is appropriate.


Richard Huxton wrote:

> Suha Onay wrote:
>
>> Hi,
>> I have a problem with PostgreSQL 7.4. (With the old one 7.3 no
>> probllem.)
>
>
> You might get a better response from the jdbc list.
>
>> I create a connection and a statement :
>>        Class.forName("org.postgresql.Driver");
>>        conn = DriverManager.getConnection(
>>                        O_Constants.DB_CONNECTION_URL,
>>                        O_Constants.DB_CONNECTION_USERNAME,
>>                        O_Constants.DB_CONNECTION_PASSWORD);
>>        st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
>> ResultSet.CONCUR_UPDATABLE);
>>        rs = st.executeQuery("select * ...";
>>
>> Then:
>>    rs.updateString(20 , ...);
>>
>> The error is:
>> org.postgresql.util.PSQLException: Cannot update the result set
>> because it is either before the start or after the end of the results.
>
>
> What happens if you fetch a row first?
>

Re: updateString error in PostgreSQL7.4 with JDBC

From
Kris Jurka
Date:

On Wed, 10 Nov 2004, Suha Onay wrote:

>         st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
> ResultSet.CONCUR_UPDATABLE);
>         rs = st.executeQuery("select * ...";
>
> Then:
>     rs.updateString(20 , ...);
>
> The error is:
> org.postgresql.util.PSQLException: Cannot update the result set because
> it is either before the start or after the end of the results.


You must be on a row (or the insert row) to update it, you have not shown
any positioning methods (like next()) being called on the ResultSet so it
is left positioned before the first row.  I don't know what the 7.3 driver
was actually doing, but this error is the expected behavior of the driver,
unless of course you are doing something else you haven't shown us.

Kris Jurka