pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedPostgres JDBC
8+ messages / 8 participants
[nested] [flat]
* Postgres JDBC
@ 2002-07-23 14:07 Amel Mammar <mammar@iie.cnam.fr>
2002-07-23 14:13 ` Re: Postgres JDBC Marc Sturm <marc_wea@yahoo.com>
2002-07-23 14:45 ` Re: Postgres JDBC Andrew Sullivan <andrew@libertyrms.info>
0 siblings, 2 replies; 8+ messages in thread
From: Amel Mammar @ 2002-07-23 14:07 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I need your help.
I have tried to instal the JDBC driver for Postgres using
--with-java option of configure command.
The error ant doesn't work is occured.
I have already installed the ANT.
Can someone give me the steps I must follows to install
correctly the JDBC.
Thank You for your help.
--
----------------------------------------------------
Amel MAMMAR
CEDRIC-IIE, INSTITUT INFORMATIQUE D'ENTREPRISE
18 allee J.Rostand
F-91025 EVRY CEDEX (FRANCE)
Tel : +33 (1) 69 36 73 73
Fax : +33 (1) 69 36 73 05
E-mail:mammar@iie.cnam.fr
----------------------------------------------------
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres JDBC
2002-07-23 14:07 Postgres JDBC Amel Mammar <mammar@iie.cnam.fr>
@ 2002-07-23 14:13 ` Marc Sturm <marc_wea@yahoo.com>
1 sibling, 0 replies; 8+ messages in thread
From: Marc Sturm @ 2002-07-23 14:13 UTC (permalink / raw)
To: Amel Mammar <mammar@iie.cnam.fr>; pgsql-jdbc
I would get a binary jdbc driver at http://jdbc.postgresql.org/download.html
Ready for use.
Marc
----- Original Message -----
From: Amel Mammar
To: pgsql-jdbc@postgresql.org
Sent: Tuesday, July 23, 2002 10:07 AM
Subject: [JDBC] Postgres JDBC
Hello,
I need your help.
I have tried to instal the JDBC driver for Postgres using
--with-java option of configure command.
The error ant doesn't work is occured.
I have already installed the ANT.
Can someone give me the steps I must follows to install
correctly the JDBC.
Thank You for your help.
--
----------------------------------------------------
Amel MAMMAR
CEDRIC-IIE, INSTITUT INFORMATIQUE D'ENTREPRISE
18 allee J.Rostand
F-91025 EVRY CEDEX (FRANCE)
Tel : +33 (1) 69 36 73 73
Fax : +33 (1) 69 36 73 05
E-mail:mammar@iie.cnam.fr
----------------------------------------------------
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres JDBC
2002-07-23 14:07 Postgres JDBC Amel Mammar <mammar@iie.cnam.fr>
@ 2002-07-23 14:45 ` Andrew Sullivan <andrew@libertyrms.info>
1 sibling, 0 replies; 8+ messages in thread
From: Andrew Sullivan @ 2002-07-23 14:45 UTC (permalink / raw)
To: pgsql-jdbc
On Tue, Jul 23, 2002 at 04:07:54PM +0200, Amel Mammar wrote:
> The error ant doesn't work is occured.
> I have already installed the ANT.
But probably your system doesn't know about it. Is it in your
CLASSPATH? You'll need it there when building.
A
--
----
Andrew Sullivan 87 Mowat Avenue
Liberty RMS Toronto, Ontario Canada
<andrew@libertyrms.info> M6K 3E3
+1 416 646 3304 x110
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres JDBC
@ 2003-07-09 15:48 Barry Lind <blind@xythos.com>
0 siblings, 0 replies; 8+ messages in thread
From: Barry Lind @ 2003-07-09 15:48 UTC (permalink / raw)
To: Arun Desai <Arundesai@kinera.com>; +Cc: pgsql-jdbc
Arun,
Here are a couple of things I would recommend:
1) Don't include transaction control code in your sql. Use the JDBC
methods to do this (i.e. setAutocommit()).
2) Don't include more than one statement in a sql string. (i.e. "FETCH
ALL IN funcursor; CLOSE funcursor;", should be two different calls
"FETCH ALL IN funcursor" and "CLOSE funcursor"). This may work now, but
likely won't work in the future.
3) Turn on SQL statement tracing in the server (set log_statement=ture
in postgresql.conf file). This will allow you to see the exact
statements being sent to the server from the driver and will likely help
you identifiy how/why this isn't working.
4) The latest driver builds can be found at jdbc.postgresql.org
5) If you have any further questions, please send them to the
pgsql-jdbc@postgresql.org mail list. That way others can contribute and
everyone benefits from the exchange in information.
thanks,
--Barry
Arun Desai wrote:
> Barry,
> We are using Postgresql 7.3.3. We are encountering following problems when JDBC is used to access Postgresql DB from a Java application (using JDK1.3.1_06).
>
> My test program does the following:
> a. get a DB connection from a connection pool. For ex: con
>
> b. Using Connection obtained in a) execute a function that returns a Refcursor.
> In Java I do the following:
>
> String str = "begin; select sp_test_select (?, 'funcsursor');"
> PreparedStatement pstmtTmp = con.prepareStatement(str);
> pstmtTmp.setInt(1, 1);
> ResultSet rsTmp = pstmtTmp.executeQuery();
> PreparedStatement pstmt = conn.prepareStatement("FETCH ALL IN funcursor; CLOSE funcursor;");
> ResultSet rs = pstmt.executeQuery();
> // Use rs
> .
> .
> rs.close();
> pstmt.close();
> rsTmp.close();
> pstmtTmp.close();
>
> This is my Postgresql Function that returns a refcursor.
>
> CREATE OR REPLACE FUNCTION sp_test_select (numeric, refcursor) returns refcursor as '
> DECLARE
> id_no alias for $1;
> refc alias for $2;
> BEGIN
> OPEN refc FOR SELECT * FROM testtable WHERE idno = id_no;
> RETURN refc;
> END;
> ' LANGUAGE 'plpgsql';
>
>
> c. Using the same Connection object obtained in a) execute a function that does not return Refcursor but updates some table. This step is carried out after executing step b). This update is failing. No exception but update does not take place. If I skip step b) and carry out only steps a) and c) update works fine.
>
>
> Am I doing something wrong in step b).
>
>
> Also where do I get the latest JDBC driver patch for Postgresql 7.3.3.
>
>
> Any help will be highly appreciated.
>
>
> Thanks,
> Arun Desai.
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* postgres-jdbc
@ 2005-03-17 13:40 aparna <aparna@chintech.org>
2005-03-17 13:47 ` Re: postgres-jdbc mikael-aronsson <mikael-aronsson@telia.com>
2005-03-17 13:56 ` Re: postgres-jdbc Roland Walter <rwa@mosaic-ag.com>
2005-03-17 13:56 ` Re: postgres-jdbc Chris Smith <cdsmith@twu.net>
0 siblings, 3 replies; 8+ messages in thread
From: aparna @ 2005-03-17 13:40 UTC (permalink / raw)
To: pgsql-jdbc
hi
I'm a computer student.
as part of my mini project i'm working on the project GUI frontend for
postgres.
i'm doing it in Java.
Is there any way to retrieve the structure of a table from the java
program and display it?
I tried to execute the command \d using the program.
it worked.
But i couldn't get the result.
Can anybody help?
Please send mail to
aparna@chintech.org
--regards aparna
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: postgres-jdbc
2005-03-17 13:40 postgres-jdbc aparna <aparna@chintech.org>
@ 2005-03-17 13:47 ` mikael-aronsson <mikael-aronsson@telia.com>
2 siblings, 0 replies; 8+ messages in thread
From: mikael-aronsson @ 2005-03-17 13:47 UTC (permalink / raw)
To: aparna <aparna@chintech.org>; pgsql-jdbc
Hi !
The meta data gives all information you need about the tablöe, for example
to get column names you could:
ResultSet rs = ....
ResultSetMetaData meta = rs.getMetaData();
int count = meta.getColumnCount();
String[] cols = new String[ count];
int i;
for( i = 1; i <= count; i++)
cols[ i - 1] = meta.getColumnLabel( i);
I am not sure if this is what you want, if it is this all part of the JDBC
standard so just look it up in the JDBC docs.
Mikael
----- Original Message -----
From: "aparna" <aparna@chintech.org>
To: <pgsql-jdbc@postgresql.org>
Sent: Thursday, March 17, 2005 2:40 PM
Subject: [JDBC] postgres-jdbc
> hi
> I'm a computer student.
> as part of my mini project i'm working on the project GUI frontend for
> postgres.
>
> i'm doing it in Java.
> Is there any way to retrieve the structure of a table from the java
> program and display it?
>
> I tried to execute the command \d using the program.
> it worked.
> But i couldn't get the result.
> Can anybody help?
> Please send mail to
> aparna@chintech.org
> --regards aparna
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: postgres-jdbc
2005-03-17 13:40 postgres-jdbc aparna <aparna@chintech.org>
@ 2005-03-17 13:56 ` Roland Walter <rwa@mosaic-ag.com>
2 siblings, 0 replies; 8+ messages in thread
From: Roland Walter @ 2005-03-17 13:56 UTC (permalink / raw)
To: aparna <aparna@chintech.org>; +Cc: pgsql-jdbc
java.sql.Connection offers the method getMetaData() that returns
a java.sql.DatabaseMetaData object.
Refer to the java api at
http://java.sun.com/j2se/1.5.0/docs/api/index.html
for further information of usage.
--
Roland Walter
MOSAIC SOFTWARE AG
Telefon: 02225/882-411 Fax: 02225/882-201
http://www.mosaic-ag.com
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: postgres-jdbc
2005-03-17 13:40 postgres-jdbc aparna <aparna@chintech.org>
@ 2005-03-17 13:56 ` Chris Smith <cdsmith@twu.net>
2 siblings, 0 replies; 8+ messages in thread
From: Chris Smith @ 2005-03-17 13:56 UTC (permalink / raw)
To: aparna <aparna@chintech.org>; +Cc: pgsql-jdbc
aparna wrote:
> i'm doing it in Java.
> Is there any way to retrieve the structure of a table from the java
> program and display it?
>
> I tried to execute the command \d using the program.
> it worked.
> But i couldn't get the result.
\d is a meta-command in psql, and it only works in psql. The same basic
information, though, is available through JDBC. Take a look at the
java.sql.DatabaseMetaData class in your copy of the Java API documentation.
Basically, once you've opened a connection of the database, call getMetaData
on the connection, and then call methods of the resulting class.
The columns in a table are available by calling getColumns(...) on
DatabaseMetaData.
The results are (confusingly) returned in a ResultSet instead of a more
specific data structure, so you'll need to make frequent reference to the
API documentation in order to interpret what you get back. Also, since the
structure of that ResultSet is specified by Java and not by PostgreSQL,
there will be many inapplicable or undeterminable columns. However, it will
give you the same information provided about table columns by "\d" in psql.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2005-03-17 13:56 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-07-23 14:07 Postgres JDBC Amel Mammar <mammar@iie.cnam.fr>
2002-07-23 14:13 ` Marc Sturm <marc_wea@yahoo.com>
2002-07-23 14:45 ` Andrew Sullivan <andrew@libertyrms.info>
2003-07-09 15:48 Re: Postgres JDBC Barry Lind <blind@xythos.com>
2005-03-17 13:40 postgres-jdbc aparna <aparna@chintech.org>
2005-03-17 13:47 ` Re: postgres-jdbc mikael-aronsson <mikael-aronsson@telia.com>
2005-03-17 13:56 ` Re: postgres-jdbc Roland Walter <rwa@mosaic-ag.com>
2005-03-17 13:56 ` Re: postgres-jdbc Chris Smith <cdsmith@twu.net>
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