Re: describe table query?

From: snpe <snpe(at)snpe(dot)co(dot)yu>
To: Dan Ostrowski <dan(at)triad-dev(dot)com>
Cc: toastafari(at)yahoo(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: describe table query?
Date: 2002-09-10 02:21:03
Message-ID: 200209100421.03308.snpe@snpe.co.yu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,
This is example.You see JDBC specification on sun.java.com
regards
import java.io.*;
import java.sql.*;
import java.text.*;

public class poruka
{
Connection db;

public poruka(String driver,String url,String user,String passwd) throws
ClassNotFoundException, FileNotFoundException, IOException, SQLException
{
Class.forName(driver);
db = DriverManager.getConnection(url,user,passwd);
DatabaseMetaData dbmd = db.getMetaData();


ResultSet rs=dbmd.getTables(null,null,null,new String[] {"TABLE"});
while (rs.next()) {
String ime=rs.getString(1);
System.out.print("1 " + ime + " ");
ime=rs.getString(2);
System.out.print("2 " + ime + " ");
ime=rs.getString(3);
System.out.print("3 " + ime + " ");
ime=rs.getString(4);
System.out.print("4 " + ime + " ");
ime=rs.getString(5);
System.out.print("5 " + ime + " ");
System.out.println();
}

db.close();
}

public static void main(String args[])
{
System.out.println("JDBC test \n");

try
{
poruka test = new poruka(args[0],args[1],args[2],args[3]);
}
catch (Exception ex)
{
System.err.println("Exception caught.\n" + ex);
ex.printStackTrace();
}
}
}

On Tuesday 10 September 2002 03:55 am, Dan Ostrowski wrote:
> I also would love to know how you do this, because I am REALLY missing the
> "DESCRIBE <table>" calls...
>
> I work with mostly PHP4...
>
> please help!
>
> regards,
> dan
>
> On Tue, 10 Sep 2002 03:07:46 +0200
>
> snpe <snpe(at)snpe(dot)co(dot)yu> wrote:
> > If You use java then that is DatabaseMetaData.getColumns etc
> >
> > regards
> > Haris Peco
> >
> > On Monday 09 September 2002 11:30 pm, Andrew Bulmer wrote:
> > > I'm trying to write an Access clone in java that will
> > > use PostGres as a backend. Problem is, I need to be
> > > able to list all the fields (and data types) in a
> > > table. I know about "\d" but that only seems to work
> > > on the command line client (doesn't work if I pass it
> > > in as a query). I know in mysql DESCRIBE <table> will
> > > do it... is there an equivalent in postgres? I tried
> > > google but all I could find were references to the \d command.
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Finance - Get real-time stock quotes
> > > http://finance.yahoo.com
> > >
> > > ---------------------------(end of
> > > broadcast)--------------------------- TIP 2: you can get off all lists
> > > at once with the unregister command (send "unregister
> > > YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message snpe 2002-09-10 02:24:22 Re: AutoCommit mode in PostgreSQL (7.3 beta1 from CVS 05.09.2002)
Previous Message Dan Ostrowski 2002-09-10 01:55:40 Re: describe table query?