pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jose.Silva@isotrol.com
To: pgsql-jdbc@postgresql.org
Subject: UPDATE with JDBC fail
Date: Thu, 5 Aug 2004 12:32:44 +0200 (CEST)
Message-ID: <33339.192.168.102.86.1091701964.squirrel@192.168.102.86> (raw)

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



view thread (6+ messages)  latest in thread

Message-ID: <33339.192.168.102.86.1091701964.squirrel@192.168.102.86>
Permalink:  ../33339.192.168.102.86.1091701964.squirrel@192.168.102.86/
Also on:    postgresql.org/message-id/33339.192.168.102.86.1091701964.squirrel@192.168.102.86

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Jose.Silva@isotrol.com
  Subject: Re: UPDATE with JDBC fail
  In-Reply-To: <33339.192.168.102.86.1091701964.squirrel@192.168.102.86>
  References: <33339.192.168.102.86.1091701964.squirrel@192.168.102.86>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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