pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Questión of JDBC
3+ messages / 3 participants
[nested] [flat]

* Questión of JDBC
@ 2007-09-05 00:02  Miguel Angel . <rev_angel@hotmail.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Miguel Angel . @ 2007-09-05 00:02 UTC (permalink / raw)
  To: pgsql-jdbc

What so.
I am a programmer in java and I want to design a module that allows me to 
read the consultations that I make within poststoneware without concerning 
the amount of columns nor the name of the same ones.
So my question is:
Within the JDBC that class allows me to obtain this data of the 
consultations that I make to the data base?

Something thus:
SELECT * FROM tableA INNER JOIN tableB USING(column);

columnA | columnB
------------------
10     |   20

I need this:

query
-------
columnA
columnB

This can be obtained by means of the JDBC?

_________________________________________________________________
Moda para esta temporada. Ponte al día de todas las tendencias. 
http://www.msn.es/Mujer/moda/default.asp




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

* Re: [JDBC] Questión of JDBC
@ 2007-09-05 08:35  Heikki Linnakangas <heikki@enterprisedb.com>
  parent: Miguel Angel . <rev_angel@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Heikki Linnakangas @ 2007-09-05 08:35 UTC (permalink / raw)
  To: Miguel Angel . <rev_angel@hotmail.com>; +Cc: pgsql-jdbc

Miguel Angel . wrote:
> Something thus:
> SELECT * FROM tableA INNER JOIN tableB USING(column);
> 
> columnA | columnB
> ------------------
> 10     |   20
> 
> I need this:
> 
> query
> -------
> columnA
> columnB
> 
> This can be obtained by means of the JDBC?

Yes, see ResultSet.getMetaData().

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com



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

* RE: [JDBC] Questión of JDBC
@ 2007-09-05 10:34  Albe Laurenz <laurenz.albe@wien.gv.at>
  parent: Miguel Angel . <rev_angel@hotmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Albe Laurenz @ 2007-09-05 10:34 UTC (permalink / raw)
  To: Miguel Angel . *EXTERN* <rev_angel@hotmail.com>; pgsql-jdbc

Miguel Angel wrote:
> I am a programmer in java and I want to design a module that
> allows me to read the consultations that I make within poststoneware
> without concerning the amount of columns nor the name of the same ones.
> So my question is:
> Within the JDBC that class allows me to obtain this data of the
> consultations that I make to the data base?

Sorry, I don't understand this at all, but I'll read on,
maybe it will become clear from the examples:

> Something thus:
> SELECT * FROM tableA INNER JOIN tableB USING(column);
> 
> columnA | columnB
> ------------------
> 10     |   20
> 
> I need this:
> 
> query
> -------
> columnA
> columnB
> 
> This can be obtained by means of the JDBC?

Do you want to get the java.sql.ResultSetMetaData of the query?

That can be had with java.sql.ResultSet.getMetaData(), see
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html#getMetaData()

The ResultSetMetaData will give you the names chosen for the
result columns.

Or do you want to get the names of the columns of a table?

That can be obtained with the following PostgreSQL query:

SELECT column_name
  FROM information_schema.columns
  WHERE table_name='mytable' AND table_schema='myschema'
  ORDER BY ordinal_position;

This will be of limited protability, because not all database systems
have an information_schema (although they should).

Maybe the following technique is more portable:

SELECT * FROM myschema.mytable WHERE 0=1;

This will select zero rows, you can get the ResultSetMetaData of the
(empty) ResultSet and figure out the column names.


If none of these answers your question,
please try to clarify it.

Yours,
Laurenz Albe



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


end of thread, other threads:[~2007-09-05 10:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-09-05 00:02 Questión of JDBC Miguel Angel . <rev_angel@hotmail.com>
2007-09-05 08:35 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-09-05 10:34 ` Albe Laurenz <laurenz.albe@wien.gv.at>

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