pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
UPDATE with JDBC fail
6+ messages / 3 participants
[nested] [flat]

* UPDATE with JDBC fail
@ 2004-08-05 10:32  Jose.Silva@isotrol.com
  0 siblings, 3 replies; 6+ messages in thread

From: Jose.Silva@isotrol.com @ 2004-08-05 10:32 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: UPDATE with JDBC fail
@ 2004-08-05 14:19  Kris Jurka <books@ejurka.com>
  parent: Jose.Silva@isotrol.com
  2 siblings, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2004-08-05 14:19 UTC (permalink / raw)
  To: Jose.Silva@isotrol.com; +Cc: pgsql-jdbc



On Thu, 5 Aug 2004 Jose.Silva@isotrol.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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: UPDATE with JDBC fail
@ 2004-08-05 21:55  Oliver Jowett <oliver@opencloud.com>
  parent: Jose.Silva@isotrol.com
  2 siblings, 0 replies; 6+ messages in thread

From: Oliver Jowett @ 2004-08-05 21:55 UTC (permalink / raw)
  To: Jose.Silva@isotrol.com; +Cc: pgsql-jdbc

Jose.Silva@isotrol.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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: UPDATE with JDBC fail
@ 2004-08-05 21:58  Oliver Jowett <oliver@opencloud.com>
  parent: Jose.Silva@isotrol.com
  2 siblings, 1 reply; 6+ messages in thread

From: Oliver Jowett @ 2004-08-05 21:58 UTC (permalink / raw)
  To: Jose.Silva@isotrol.com; +Cc: pgsql-jdbc

Jose.Silva@isotrol.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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: UPDATE with JDBC fail
@ 2004-08-05 22:17  Kris Jurka <books@ejurka.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Kris Jurka @ 2004-08-05 22:17 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Jose.Silva@isotrol.com; 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: UPDATE with JDBC fail
@ 2004-08-05 22:49  Oliver Jowett <oliver@opencloud.com>
  parent: Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Oliver Jowett @ 2004-08-05 22:49 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Jose.Silva@isotrol.com; 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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2004-08-05 22:49 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-08-05 10:32 UPDATE with JDBC fail Jose.Silva@isotrol.com
2004-08-05 14:19 ` Kris Jurka <books@ejurka.com>
2004-08-05 21:55 ` Oliver Jowett <oliver@opencloud.com>
2004-08-05 21:58 ` Oliver Jowett <oliver@opencloud.com>
2004-08-05 22:17   ` Kris Jurka <books@ejurka.com>
2004-08-05 22:49     ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox