pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Dave Cramer <pg@fastcrypt.com>
To: vasylenko@uksatse.org.ua
Cc: pgsql-jdbc@postgresql.org
Subject: Re: How to Insert the Row in ResultSet by moveToInsertRow() ... insertRow()?
Date: Wed, 10 Jan 2007 07:06:45 -0500
Message-ID: <6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com> (raw )
In-Reply-To: <OFD168223B.F807FA6D-ONC225725F.003AF87A-C225725F.003B52A4@UKCC.UKSATSE >
References: <OFD168223B.F807FA6D-ONC225725F.003AF87A-C225725F.003B52A4@UKCC.UKSATSE >
On 10-Jan-07, at 5:47 AM, vasylenko@uksatse.org.ua wrote:
>
>
> Hello!
> |---------------------------------------------------------------------
> -----|
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> | I've got the Postgre database and table
> insdide |
> |
> |
> |
> code: |
> |
> |
> |
> |
> |
> |
> |
> |
> | CREATE TABLE
> groups |
> |
> ( |
> | id int4 NOT NULL DEFAULT nextval
> ('seq_group_id'::regclass), |
> | g_name text NOT
> NULL, |
> | CONSTRAINT i_group PRIMARY KEY
> (id) |
> | )
> |
> | WITHOUT
> OIDS; |
> | ALTER TABLE groups OWNER TO
> vasylenko; |
> | COMMENT ON TABLE groups IS 'Группы
> работников (объект, смена |
> | ...)';
> |
> |
> |
> |
> |
> |
> |
> |
> |
> | As You can see: 2
> fields |
> | id - it's an autofill
> field. |
> |
> |
> | But when I try to insert the new Row in code putting
> under It |
> | generete the SQLException, that "id" filed was not found
> in |
> | ResultSet. But it mustn't be there as for
> me. |
> | I created the id field with default value from the
> sequence |
> |
> code: |
> |
> |
> |
> |
> |
> |
> | CREATE SEQUENCE
> seq_group_id |
> | INCREMENT
> 1 |
> | MINVALUE
> 1 |
> | MAXVALUE
> 9223372036854775807 |
> | START
> 26 |
> | CACHE
> 1; |
> | ALTER TABLE seq_group_id OWNER TO
> vasylenko; |
> |
> |
> |
> |
> |
> |
> |
> |
> | The Code
> is: |
> |
> code: |
> |
> |
> |
> |
> |
> |
> | ResultSet
> rs; |
> | Statement stat
> = |
> | conn.createStatement
> (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CO|
> |
> NCUR_UPDATABLE); |
You only selected g_name , not id, g_name
Dave
> | rs = stat.executeQuery("Select g_name FROM
> groups"); |
> | try
> { |
> | rs.moveToInsertRow
> (); |
> | /
> ** |
> | ** !!!!!!!The exception generated
> there !!!!!!!!! |
> |
> */ |
> | }
> |
> | catch(SQLException ex)
> { |
> |
> |
> | System.out.print(ex.getMessage()
> +"\n"); |
> |
> return; |
> | }
> |
> |
> |
> | try
> { |
> | String temp = "New
> Group"; |
> |
> |
> | rs.updateObject(i+1,
> temp); |
> | }
> |
> |
> |
> | catch(SQLException ex)
> { |
> |
> |
> | System.out.print(ex.getMessage()
> +"\n"); |
> |
> return; |
> | }
> |
> |
> |
> |
> |
> | try
> { |
> | rs.insertRow
> (); |
> | }
> |
> | catch(SQLException
> ex) |
> |
> { |
> |
> |
> | System.out.print(ex.getMessage()
> +"\n"); |
> |
> |
> | }
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> |
> | I don't neew to make the ResultSet with both fields...
> 'cos I use|
> | this ResultSet Data in JTable table
> model. |
> | How to solve the
> problem? |
> |
> Thanks. |
> |
> |
> |
> |
> |
> |
> |
> |
> |---------------------------------------------------------------------
> -----|
>
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
view thread (4+ messages) latest in thread
Message-ID: <6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com>
Permalink: ../6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com/
Also on: postgresql.org/message-id/6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com
copy link · copy postgr.es
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: pg@fastcrypt.com, vasylenko@uksatse.org.ua
Subject: Re: How to Insert the Row in ResultSet by moveToInsertRow() ... insertRow()?
In-Reply-To: <6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com>
References: <OFD168223B.F807FA6D-ONC225725F.003AF87A-C225725F.003B52A4@UKCC.UKSATSE> <6FBFEA2D-BAE3-4420-9685-3FA10E070A54@fastcrypt.com>
* 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