pg.ddx.io pgsql-interfaces@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Detecting presence of database through JDBC? 2+ messages / 2 participants [nested] [flat]
* Detecting presence of database through JDBC? @ 2000-05-16 18:19 Steve Wampler <swampler@noao.edu> 2000-05-16 19:21 ` Re: Detecting presence of database through JDBC? Peter Mount <peter@retep.org.uk> 0 siblings, 1 reply; 2+ messages in thread From: Steve Wampler @ 2000-05-16 18:19 UTC (permalink / raw) To: pgsql-interfaces Is there a way to determine whether or not a particular database exists programmatically throught JDBC? I was expecting an exception to be thrown if the DriverManager.getConnection(url, user, pwd) method cannot complete, but instead I get a "FATAL" error that doesn't seem to be catchable. (I'd like the program to automatically create a database if it doesn't yet exist and then populate it with the tables that are needed. Handling the tables is easy, but I haven't found a way around the test for the database yet...) Thanks for any help! Steve -- Steve Wampler- SOLIS Project, National Solar Observatory swampler@noao.edu ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Detecting presence of database through JDBC? 2000-05-16 18:19 Detecting presence of database through JDBC? Steve Wampler <swampler@noao.edu> @ 2000-05-16 19:21 ` Peter Mount <peter@retep.org.uk> 0 siblings, 0 replies; 2+ messages in thread From: Peter Mount @ 2000-05-16 19:21 UTC (permalink / raw) To: Steve Wampler <swampler@noao.edu>; +Cc: pgsql-interfaces On Tue, 16 May 2000, Steve Wampler wrote: > > Is there a way to determine whether or not a particular database > exists programmatically throught JDBC? I was expecting an > exception to be thrown if the DriverManager.getConnection(url, user, pwd) > method cannot complete, but instead I get a "FATAL" error that > doesn't seem to be catchable. The easiest way is to connect to the template1 database, then query the system tables for the database. This is exactly how PSQL implements the -l parameter. PS: In standard JDBC, there is no way of geting a list of databases on a particular server. Peter > (I'd like the program to automatically create a database if it doesn't > yet exist and then populate it with the tables that are needed. Handling > the tables is easy, but I haven't found a way around the test for the > database yet...) > > Thanks for any help! > Steve > -- > Steve Wampler- SOLIS Project, National Solar Observatory > swampler@noao.edu > -- Peter T Mount peter@retep.org.uk Main Homepage: http://www.retep.org.uk PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres Java PDF Generator: http://www.retep.org.uk/pdf ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-05-16 19:21 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2000-05-16 18:19 Detecting presence of database through JDBC? Steve Wampler <swampler@noao.edu> 2000-05-16 19:21 ` Peter Mount <peter@retep.org.uk>
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