Re: problem in using DatabaseMetaData getColumns()

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: vcarun(at)yahoo(dot)co(dot)uk
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: problem in using DatabaseMetaData getColumns()
Date: 2002-09-03 16:03:48
Message-ID: 1031069028.19016.487.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

The latest code should work, can you build from cvs?

dave
On Mon, 2002-09-02 at 10:49, arun vc wrote:
> hello
>
> i am getting error while using uisng
> dmd.getColumns(null,null,MY_TABLE_NAME,null);
> i am gtting error while using the new pgjdbc2.jar
> driver with the old driver postgresql.jar this method
> is working .can you help me in solving this problem.
> i am sending a sample code
>
>
> import java.sql.DatabaseMetaData;
> import java.sql.SQLException;
> import java.sql.ResultSet;
>
> class CheckDB
> {
> public static void main(String args[])throws
> Exception{
>
> String MY_TABLE_NAME="computers";
> Connection con;
>
> try
> {
>
> Class.forName("org.postgresql.Driver");
> con =
> DriverManager.getConnection(jdbc:postgresql://localhost/mytab,loginname,password);
>
> DatabaseMetaData dmd = con.getMetaData();
> String[] tableType = {"TABLE"};
>
> ResultSet rs = dmd.getTables(null, null, null,
> tableType);
>
> while ( rs.next() )
> {
> if(MY_TABLE_NAME.equals(rs.getString( "TABLE_NAME"
> )))
> System.out.println(MY_TABLE_NAME +" found in
> database " ) ;
> }
> rs.close();
>
> rs = dmd.getColumns(null,null,MY_TABLE_NAME,null);
> // when i try to use
> getColumns(null,null,MY_TABLE_NAME,null); method
> // i am getting exception :ERROR: parser: parse
> error at or near "("
> // i am gtting this error while using the new
> pgjdbc2.jar Driver
> // with the old driver postgresql.jar this method is
> working
>
> while(rs.next())
> {
> colNames[totalFields]=rs.getString( "COLUMN_NAME"
> );//here COLUMN_NAME is a key word
> System.out.println("COLUMN_NAME : " +
> colNames[totalFields]);
> }
> rs.close();
>
> }
> catch(SQLException e)
> {
> System.out.println("here i am :"+e.getMessage());
>
> }
> }
> }
>
>
> =====
>
> would you like to help someone see the beauty of the world through your eyes long after you have gone http://www.ebai.org
>
> Arun VC, E Team India Web Solutions,
> Serene,Anupama Nagar,Pongummoodu,Trivandrum
> Phone Off: +91 471 558089. Res : +91 471 343954.
> http://www.e-zenit.it
> http://www.geocities.com/vcarun
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Barry Lind 2002-09-03 17:19:43 Re: 7.3 support?
Previous Message Jason Stewart 2002-09-03 14:31:24 Re: A JDBC driver problem