Re: UPDATE with JDBC fail

Lists: pgsql-jdbc
From: Jose(dot)Silva(at)isotrol(dot)com
To: pgsql-jdbc(at)postgresql(dot)org
Subject: UPDATE with JDBC fail
Date: 2004-08-05 10:32:44
Message-ID: 33339.192.168.102.86.1091701964.squirrel@192.168.102.86
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi, my name is J.A. Silva
I'm a worker of Isotrol (Spain).
I'm developing a tool for modify values in a PostGreSQL database.
The tool only have to modify some tables with a random value.

The code that do this is ...
private void refrescaTablaDatos()
{
String sql = "";
String molino;
ResultSet rs = null;
int i = 0;

try
{
// select the primary keys of the items to modify
sql = "SELECT DISTINCT id FROM datos;";
rs = this.con.executeSQL(sql);

// modify one per one all the items ...
while(rs.next())
{
molino = rs.getString(1);

sql = "UPDATE datos SET valor = " +
(float)(100*Math.random()) +
", timestamp = now() WHERE id = " +
molino + ";";

this.con.executeSQL(sql);
i = i + this.con.getFilasAfectadas();
}
}
catch(Exception e)
{
e.toString();
}
}

The function is very simple ... but it does not work.
The database doen not change its values.

The select query works perfectly but the update funtion does not do anything.

I hope that you can help me. I will be expecting your answer.

The PosrGre version that I use is 7.1. and the JDBC driver that I use is
the driver that you can get of Postgre's webpage.

My english level is not good, I hope that you can understand this mail.

Thanks for all and good bye


From: Kris Jurka <books(at)ejurka(dot)com>
To: Jose(dot)Silva(at)isotrol(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UPDATE with JDBC fail
Date: 2004-08-05 14:19:19
Message-ID: Pine.BSO.4.56.0408050915240.19085@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Thu, 5 Aug 2004 Jose(dot)Silva(at)isotrol(dot)com wrote:

> The function is very simple ... but it does not work.
> The database doen not change its values.
>
> The select query works perfectly but the update funtion does not do anything.
>

Any chance you have autocommit set to false and are not issuing a commit
at the end of your code?

Kris Jurka


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Jose(dot)Silva(at)isotrol(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UPDATE with JDBC fail
Date: 2004-08-05 21:55:55
Message-ID: 4112ACEB.2080301@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Jose(dot)Silva(at)isotrol(dot)com wrote:

> rs = this.con.executeSQL(sql);

There is no executeSQL() method on java.sql.Connection.

There might be one down in the guts of the driver implementation
classes, but you certainly shouldn't be using that.

What is the 'con' object, really? We need to see how the driver-level
objects are used to be of any help.

-O


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Jose(dot)Silva(at)isotrol(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UPDATE with JDBC fail
Date: 2004-08-05 21:58:16
Message-ID: 4112AD78.8010507@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Jose(dot)Silva(at)isotrol(dot)com wrote:

> The PosrGre version that I use is 7.1. and the JDBC driver that I use is
> the driver that you can get of Postgre's webpage.

Also, I've stopped testing against 7.1 (and I think Kris has too) --
it's getting very old now. I think that at least
setTransactionIsolation() will not work correctly with the current
driver against a 7.1 server. I'd strongly recommend you upgrade to a
more recent server if you can, not only for a tested driver but also for
any number of server-side bugfixes..

-O


From: Kris Jurka <books(at)ejurka(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Jose(dot)Silva(at)isotrol(dot)com, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UPDATE with JDBC fail
Date: 2004-08-05 22:17:11
Message-ID: Pine.BSO.4.56.0408051711020.2495@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Fri, 6 Aug 2004, Oliver Jowett wrote:

> Also, I've stopped testing against 7.1 (and I think Kris has too) --
> it's getting very old now. I think that at least
> setTransactionIsolation() will not work correctly with the current
> driver against a 7.1 server.

I only run specific tests against old versions when modifying something in
that area because the regression tests haven't run successfully
against 7.1 in the time I've been working on the driver. If we know the
driver doesn't work against old server versions we should refuse to
connect or issue some kind of error message. Are there things other than
transaction isolation you'd like me to test against 7.0 or 7.1?

Kris Jurka


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Jose(dot)Silva(at)isotrol(dot)com, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: UPDATE with JDBC fail
Date: 2004-08-05 22:49:52
Message-ID: 4112B990.3010209@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Kris Jurka wrote:

> I only run specific tests against old versions when modifying something in
> that area because the regression tests haven't run successfully
> against 7.1 in the time I've been working on the driver. If we know the
> driver doesn't work against old server versions we should refuse to
> connect or issue some kind of error message. Are there things other than
> transaction isolation you'd like me to test against 7.0 or 7.1?

Transaction isolation was the only thing that springs to mind (when I
rearranged the protocol code, the per-transaction setting of isolation
level for older servers got thrown out), but there may well be other stuff.

I think we should either fix the regression tests to work against
7.0/7.1, or drop support for those versions entirely and refuse to
connect. I know which is easier :)

-O