Unix Technical Forum

=?iso-8859-1?B?UXVlc3Rp824gb2YgSkRCQw==?=

This is a discussion on =?iso-8859-1?B?UXVlc3Rp824gb2YgSkRCQw==?= within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> What so. I am a programmer in java and I want to design a module that allows me to ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:53 AM
Miguel Angel .
 
Posts: n/a
Default =?iso-8859-1?B?UXVlc3Rp824gb2YgSkRCQw==?=

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


---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:53 AM
Heikki Linnakangas
 
Posts: n/a
Default =?iso-8859-1?Q?Re:_=5BJDBC=5D_Questi=F3n_of_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

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:53 AM
Albe Laurenz
 
Posts: n/a
Default =?iso-8859-1?Q?RE=3A_=5BJDBC=5D_Questi=F3n_of_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/...l#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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:51 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com