Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: obtain column names in oracle via jdbc

Re: obtain column names in oracle via jdbc

From: C. Ferguson <c_ferguson_at_rationalconcepts.com>
Date: 2000/08/07
Message-ID: <398F400E.28131A92@rationalconcepts.com>#1/1

Hi,
  have you looked at using the result set metadata?

  You can't issue the describe command via jdbc. I don't recall why off the top of my head but
as you are seeing, it doesn't work.

  So, issue a sql statement along the lines of    select * from xyz where rownum < 2;

   Then from the result set, get the metadata.    You can then determine how many columns were returned and can then get the column name knowing the index.

   Or there is the user_tab_columns dictionary view that you could query.

hth,
cindy

a7244270_at_my-deja.com wrote:

> Hi,
>
> I am trying to find out what the columns in a given table are.
>
> For some reason, the Oracle jdbc driver keeps telling me
>
> > Exception java.sql.SQLException: ORA-00900: invalid SQL statement
>
> which is obviously not true.
>
> Does anyone out there have any clue how can I do this ?
>
> Alfonso.
>
> java.sql.Connection connection = pool.get();
> ResultSet rs = null;
> connection = pool.get();
>
> Statement stmt = connection.createStatement();
>
> String command = "describe xyz";
> rs = stmt.executeQuery( command );
> if ( rs.next() )
> {
> System.out.println("Col #1: " + rs.getString(1));
> }
> pool.release(connection);
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Aug 07 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US