Java JDBC 101: How to connect to a SQL database with JDBC

Java database FAQ: How do I connect to a SQL database with Java and JDBC?

If you're interested in connecting your Java applications to standard SQL databases like Oracle, MySQL, SQL Server, and others, the Java JDBC technology is exactly what you need. The combination of Java/JDBC and standard SQL queries creates a simple and powerful database solution. JDBC makes the simple things easy -- without making the complex tasks too difficult either.


How to show Postgres table information alvin February 8, 2006 - 5:58pm

Here you want to use the "describe" command in Postgresql. Assuming that you want to get information about a database table named users, and you're logged into a Postgresql database using the psql client, issue this command at the psql prompt:

\d users

This will provide a description of the table named users. Your output from this command should look like this:

Postgresql - How to list all tables in a Postgresql database alvin February 8, 2006 - 5:52pm

"Postgres show tables" FAQ: How do I list all the tables in my current Postgresql database?

Once you're logged into a Postgresql database using the psql client, issue this command at the psql prompt to show all the tables in your Postgres database:


This will list all of the tables in the current database.


How to list the Postgresql slash commands alvin February 8, 2006 - 5:48pm

Question: How do I list the Postgres slash commands, i.e., the commands available from the Postgres command line?

Once you're logged into a Postgresql database, you can issue the \? command to see the list of available Postgres "slash" commands, like this:

mydatabase=> \?

For my own convenience, I'm listing these Postgres commands here. These are the commands available in the Postgresql 8.0.3 client:

First, I issue the call for Postgres command line help:

Postgres login: How to log into a Postgresql database alvin February 8, 2006 - 5:40pm

"Postgres login" FAQ: How do I log into a Postgres database from the command line?

To log into a Postgres database from the command line, use the psql command. Let's take a look at a few psql command line options you can use.

Postgres login commands

If you are logged into the same computer that Postgres is running on you can use the following psql login command, specifying the database (mydb) and username (myuser):

Practical PostgreSQL book online alvin May 5, 2003 - 1:43pm

Don't know much about the following site, but it does contain an online version of a book titled Practical PostgreSQL.

Postgresql commands: ‘psql’ list commands alvin June 21, 2002 - 10:40am

Here's a quick tabular list of Postgres commands related to listing information about a Postgres database. (Technically these are "psql commands", because you issue these commands from the psql command line program.)

These Postgres commands help you answer questions like "What tables are in this postgres database?", or "What databases do I have within Postgres?" (a handy question when it comes time for spring cleaning), and other questions. Other popular psql commands are related to permissions, indexes, views, and sequences.

List Postgesql databases (how to)

Postgresql list FAQ: How do I get a list of databases in a Postgresql database?

Just log into your Postgresql database (with the psql command), and then run this command:


(That's a backslash followed by the lowercase letter "L"). This command provides a nice list of all of the Postgresql databases.