Re: Doubt in Value insertion to an Array column through JD

From: J M Okomba <Okomba(at)kabage(dot)co(dot)ke>
To: 'Shanmugasundaram Doraisamy' <shan(at)ceedees(dot)com>
Cc: postgresql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Doubt in Value insertion to an Array column through JD
Date: 2003-03-14 05:54:52
Message-ID: 715DF98A936DD211B29D0008C71E55D4945ADD@NTSERVER1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


Try this:

connection.prepareStatement("insert into
address_using_array values(?,?,?)");

pStmt.setString(1,"Subramanian. S");
pStmt.setArray(2, {"First Street","Friends Nagar"});
pStmt.setString(3,"ssm_pandu(at)ceedees(dot)com");

> -----Original Message-----
> From: Shanmugasundaram Doraisamy [SMTP:shan(at)ceedees(dot)com]
> Sent: 13 March 2003 04:54
> To: postgresql-jdbc
> Subject: [JDBC] Doubt in Value insertion to an Array column through
> JDBC]
>
> Dear Group,
> We are using Postgresql 7.3.1 on Redhat 7.3. The following
> is the problem I am facing:
>
> **************************************************************************
> ************************
> I am having a table with the following structure:
>
> Table Name: address_using_array
>
> COLUMN_NAME TYPE CONSTRAINT
> -------------------------------------
> 1. name text -
> 2. address text[] -
> 3. email text -
>
>
> I tried the following combinations and I got the exceptions as a
> result (It is also given).
> My java program Name is DBTestWithArrayColumn.java.
>
> a) PreparedStatement pStmt =
> connection.prepareStatement("insert into
> address_using_array values(?,{?,?},?)");
> pStmt.setString(1,"Subramanian. S");
> pStmt.setString(2,"First Street");
> pStmt.setString(3,"Friends Nagar");
> pStmt.setString(4,"ssm_pandu(at)ceedees(dot)com");
> if(pStmt.execute()) System.out.println("Successfully
> inserted");
>
> Output:
> ------
> java.sql.SQLException: ERROR: parser: parse error at or
> near "{" at character 58
> at
> DBTestWithArrayColumn.main(DBTestWithArrayColumn.java:28)
>
>
> The doubt is "How to insert values to the 'address' column through
> JDBC?".
>
>
> Thanking you,
> Shanmugasundaram Doraisamy
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Browse pgsql-jdbc by date

  From Date Subject
Next Message J M Okomba 2003-03-14 08:19:19 Re: Problem with driver
Previous Message Andres Montiel 2003-03-14 04:15:52 embedding PostgreSQL in a Java application