PostgreSQL Backup and Restore

Created 05 December 2002 00:00
Backing Up

Locate the pg_dump file (usually located in /usr/local/pgsql/bin/ and run the following commands to backup your database:

pg_dump -s -f filename_schema.dmp -U username database_name
pg_dump -a -f filename_data.dmp -U username database_name
to create the schema and data dumps respectively. This will create text files with all the necessary SQL statements required to restore the database using the PostgreSQL restore feature.

Dropping the existing database

Before restoring, you may need to drop the existing database. Use the following command:

dropdb <database_name>

Restoring the database

To restore the above database, you will need to create a new database and then run the script using the psql command:

createdb --username=<user> database_name
psql -e -f filename_schema.dmp -U <user> <database_name>
psql -e -f filename_data.dmp -U <user> <database_name>
to restore the schema, and then the data.

Java : Adding actions to components

Created 06 December 2002 00:00
Actions can be very useful when two objects must perform the same action. For example, if you want a menu item and a button to do the same thing, use an action as follows:
  Action act = new AbstractAction("Does something") {
    public void actionPerformed(ActionEvent ae) {
      System.out.println("Something happened!");
  JMenuItem item = new JMenuItem(act);
  JButton btn = new JButton(act);