Sign up for an instant free trial.
Or try a fully functional demo.

Evolution Hosting is a reliable hosting environment designed expressly for Java™ applications. The myEvolution Control Center provides comprehensive management tools, automates system administration chores, and implements best practices.

PostgreSQL Database Windows Setup FAQ

  1. Overview
  2. Cygwin
  3. CygIPC
  4. PostgreSQL
  5. pgAdmin GUI
  6. JDBC
  7. Orion J2EE
  8. Credits

Installing PostgreSQL on Windows makes for an extremely powerful J2EE development platform. To read more about PostgreSQL visit the Evolution Hosting PostgreSQL general FAQ.

The following PostgreSQL-Windows setup instructions utilize the Cygwin Unix-on-Windows emulation environment in order to speed the setup process, and increase the overall power and flexibility of Windows.

Below are the steps to install, configure, and run PostgreSQL on Windows. The final step explains how to get an Orion J2EE-EJB application running on PostgreSQL.

Steps to set up PostgreSQL on Windows

  1. Cygwin

  2. Cygwin ( is a UNIX environment for Windows. It consists of two parts:
    • A DLL (cygwin1.dll) which acts as a UNIX emulation layer providing substantial UNIX API functionality.
    • A collection of tools, ported from UNIX, which provide UNIX/Linux look and feel.
    The Cygwin DLL works with all versions of Windows since Windows 95, with the exception of Windows CE.

    Installing Cygwin involves downloading the software to the target computer and initiating the install program (accept defaults unless otherwise noted). Note that the Cygwin installation program changes often and these steps may differ slightly from the current release.
    1. To obtain the software, go to and click on the Install link.
    2. Choose to save the file setup.exe to a local temp directory (e.g., d:\temp\).
    3. Launch the saved file d:\temp\setup.exe
    4. Splash Screen - click Next.
    5. Install From Screen - choose the Download from Internet install option as opposed to the Install from Internet option.
    6. Local Package Directory - place the install files in a temporary directory (e.g., d:\temp\cygwin).
    7. Direct Connection Screen - choose a connection method.
    8. Select Download Site Screen - choose a download location.
    9. Select Packages to Download Screen - Evolution Hosting recommends installing all packages. Note, however, that it is a very large intstall and may fail over 56k connections. To install everything, Click on the All list item until Install is displayed on the right side. Next, initiate the install. After this, initiate the transfer.
    10. When the transfer is complete, launch the setup.exe program again.
    11. Splash Screen - click Next.
    12. Install From Screen - this time, choose the Install from Local Directory install option for the source directory.
    13. Select Install Root Directory Screen - choose an install destinationbdirectory. Evolution Hosting typically installs Cygwin in d:\apps\cygwin\.
      Note that from this point forward d:\apps\cygwin\ will be referred to as: CYGWINHOME/.
    14. Local Package Directory - make sure it is pointing to the location that the setup files were downloaded into (should be defaulted to this, e.g., d:\temp\cygwin, then click Next.
    15. Select Packages to Install Screen - click the View button when selecting install packages until the Full option is displayed. The packages may have to be clicked on one-at-a-time in order to ensure that they are all installed. Next, initiate the install.
    16. Add the Cygwin bin d:\apps\cygwin\bin) directory to the system PATH environment variable. Note this must come after ActiveState Perl, if Perl is to be used on the computer. The Evolution Hosting tutorials Odin and Sphinx, for example, use ActiveState Perl.
      Note that the Cygwin bin directory has to be placed in the path before the Windows program directories, because the sort.exe program has to be taken from Cygwin, not Windows.

    Part of the Cygwin install actually includes PostgreSQL. Normally, one must download, compile, and configure PosgreSQL, but since Cygwin has been including the database with its download, configuration has gotten much easier. There will be no need for a separate PostgreSQL download, other than the PostgreSQL JDBC Driver and Admin GUI.

    To test the Cygwin install, launch a Cygwin shell window from the desktop or Windows Start Menu and type the ls command. It should provide a directory listing similar to the MS-DOS dir command.

    Cygwin support is available via the general Cygwin mailing list.
    PostgreSQL also has a Cygwin-PostgreSQL mailing list.

  3. CygIPC

  4. CygIPC is a cygwin utility that is required to run PostgreSQL. CygIPC provides shared memory, semaphores, and message support for cygwin. CygIPC is available at this mirror site. The binaries should come with
    Note: versions of CygIPC prior to 1.04 will not work.

    To install:
    1. Download the latest binary file (e.g., cygipc-1.10-1.tar.bz2) and save it to CYGWINHOME/ directory.
    2. Launch a Cygwin shell window from the desktop or Windows Start Menu. Extract the file to the CYGWINHOME/ directory. This should place the file ipc-deamon.exe and related files in CYGWINHOME/usr/local/ and/or subdirectories.
      Most of the packages on the CygIPC site are distributed in .tar.bz2 format. This means that they have been compressed using the 'bzip2' compression program, a patent-unencumbered algorithm that usually outperforms gzip, compress, and zip compressors. The bzip package is part of the official Cygwin distribution. So, bunzip2.exe should be sitting in the CYGWINHOME/bin directory.
      So, to install the precompiled packages from the CygIPC site:
      cd /
      bunzip2 -c <path-to-archive>/foo.tar.bz2 | tar xvf -

    To test the CygIPC install, launch a Cygwin shell window from the desktop or Windows Start Menu and type:
    ipc-daemon &
    It should echo its process number and give no errors.
    Note that the & instructs Cygwin to launch the command in its own background process.

  5. PostgreSQL

  6. Since the PosgreSQL binaries and documentation were downloaded with Cygwin, installation can begin straight-away. Here are some other sources of documentation that may help:
    • Note that the PostgreSQL Windows install README document located in /usr/doc/Cygwin/ is also an excellent resource for this entire installation guide. Here is one version of that document. This document also explains installing PostrgreSQL as a Windows Service.
    • Cygwin also comes with other documentation in the \usr\doc\postgresql-7.1.3\ directory. The /html subdirectory contains full HTML docs for the included version.

    To set up and start the first PostgreSQL database
    (note that commands are CASE SENSITIVE):
    1. launch a Cygwin shell window from the desktop or Windows Start Menu.
    2. Navigate to the directory: /usr/local/pgsql/data
      , which can be done by typing a command similar to:
      cd /usr/local/pgsql/data
      Note that the command:
      cd c:
      will switch back to the C drive.
      Also note that /cygdrive/C is a Cygwin alias for Windows drive letters. In this case it refers to a Windows C: drive.
      A shortcut can be achieved by creating an empty directory d in the /cygdrive
      Then the command mount d:/ /d can be done so that the d:\ drive can be accessed as /d instead of /cygdrive/d
    3. Now type the command:
      ipc-daemon &
      This starts a daemon necessary for PostgreSQL to run.
    4. To initialize PostgreSQL, type the command:
      initdb -W -D /cygdrive/d/apps/cygwin/usr/local/pgsql/data
      Note, the -W option prompts for a password for the new superuser. The superuser username usually defaults to Administrator.
      Note that most PostgreSQL commands accept the -? option to list information and options about commands.
    5. To start PostgreSQL Postmaster, type the command:
      postmaster -i -D /cygdrive/d/apps/cygwin/usr/local/pgsql/data
      Note, in order for the postmaster to accept TCP/IP connections (rather than just Unix domain socket connections), The -i option must be specified.
      Note that it is useful to run the Postmaster in its own window, as above, so that logging messages can be viewed. It may, however, also be run as a background process with the & option.
    6. To create the first database (here called mydb), open a new Cyqwin window and type the command:
      createdb mydb
      Note that you may use the -e option to show the query being sent to the backend.
    7. To test mydb, type the command:
      psql mydb

    8. Note that the ipc-daemon & must always be running in order to start PostgreSQL.

    PostgreSQL support is available via the general PostgreSQL mailing list.
    PostgreSQL also has a Cygwin-PostgreSQL mailing list.
    Here is a link to a PostgreSQL Windows setup newsgroup posting that may be of some help.

  7. pgAdmin GUI

  8. The pgAdmin ( GUI provides an interface to do things like add users, view data, and modify tables in the PostgreSQL database.

    To install:
    1. Go to the pgAdmin site and download the latest version
    2. Extract the file to a temp directory.
    3. Run install.exe
    4. Launch the program from the Windows Desktop or Start Menu.
    5. Enter credentials and log on to the database:
    6. At which point the admin screen should appear, resembling:

    pgAdmin support is available via the pgAdmin: mailing list.

  9. JDBC

  10. PostgreSQL has its own JDBC driver available from the PostgreSQL JDBC site.
    The driver also comes with the Cygwin install and is located here:

    To install the drivers:
    1. Download the Jar file (e.g., jdbc7.0-1.2.jar).
    2. Include the Jar file in the Java classpath of the application that will access the drivers.
    3. To use PostgreSQL with the JDBC drivers, the postmaster must be started with the -i flag. This allows TCP/IP connections to the database - a requirement of JDBC. Java does not support Unix domain sockets.
    4. The PostgreSQL pg_hba.conf file may need to be modified to allow access from the JDBC client (it comes with localhost already enabled).
      This is a standard configuration allowing open access to any local connection:
      local        all                                           trust
      host         all     trust
      This is a more restricted configuration (Evolution Hosting recommends this), which requires password authentication:
      local        all                                           password
      host         all    password
      host         mydb      password
      Note that the allows an external computer password access to mydb.
      The pg_hba.conf file and the PostgreSQL documentation contain more information.
    5. Whether in an application server datasource config settings, or in a Java class JDBC connection statement, the proper JDBC url must be provided. For PostgreSQL they are one of the following:
      • jdbc:postgresql:database
      • jdbc:postgresql://host/database
      • jdbc:postgresql://host:port/database
      Where database is the database to connect to, host is the server to connect to, and port is the port number.

    To use the drivers:
    1. Any source that uses JDBC needs to import the java.sql package, using:
      import java.sql.*;
      Note that the org.postgresql package must not be imported. If it is, the source will not compile, as javac will get confused.
    2. Before connecting to a database, the driver must be loaded. There are two methods available, and which one is best depends on the situation:
      • Implicitly loading the driver using the Class.forName() method. Loading PostgreSQL looks like this:
        This will load the driver, and while loading, the driver will automatically register itself with JDBC. Note: The forName() method can throw a ClassNotFoundException if the driver is not available.
        This is the most common method to use, but restricts code to use only Postgres. If the code may access another database system in the future, and Postgres-specific extensions are not used, then the second method is advisable.
      • Passing the driver as a parameter to the JVM as it starts, using the -D argument. For example:
        java -Djdbc.drivers=org.postgresql.Driver example.ImageViewer
        In this example, the JVM will attempt to load the driver as part of its initialization. Once done, the ImageViewer is started.
        This method is the better one to use because it allows code to be used with other database packages without recompilation. The only thing that would also change is the connection URL, which is covered next.
      One last thing: when code then tries to open a Connection, and a No driver available SQLException is thrown, there is either an issue finding the driver in the classpath, or an incorrect value in the URL parameter.
    3. With JDBC, a database must be connected to with a URL (Uniform Resource Locator). With PostgreSQL, this takes one of the following forms:
      • jdbc:postgresql:database
      • jdbc:postgresql://host/database
      • jdbc:postgresql://host:port/database
      The host name of the server. Defaults to localhost.
      The port number the server is listening on. Defaults to the Postgres standard port number (5432).
      The database name.
      To connect, a Connection instance needs to be obtained from JDBC. To do this, the DriverManager.getConnection() method is called:
      Connection db = DriverManager.getConnection(url, username, password);
    4. To close the database connection, the close() method is applied to the Connection: db.close();

    JDBC access can be tested in the next section regarding setting up Orion.

    PostgreSQL JDBC Driver support is available via the JDBC PostgreSQL mailing list.

  11. Orion J2EE

  12. The Orion ( J2EE server can be set up to use PostgreSQL in a J2EE/EJB application.

    To configure Orion:
    1. Add the PosgreSQL JDBC Driver to the classpath when launching Orion.
    2. An Orion database-schema descriptor must exist for accurate datatype interpretation. The file:
      should be created if it doesn't exist already. Here is an example postgres.xml file from Orion 1.5.3. Here is what the file looks like:
      <?xml version="1.0"?>
      <!DOCTYPE database-schema PUBLIC "-//Evermind//- Database schema"
      ""> <database-scheme name="PostGreSQL" not-null="not null" null="null" primary-key="primary key"> <type-mapping type="java.lang.String" name="varchar(255)" /> <type-mapping type="int" name="integer" /> <type-mapping type="long" name="integer" /> <type-mapping type="float" name="float" /> <type-mapping type="double" name="double precision" /> <type-mapping type="byte" name="smallint" /> <type-mapping type="char" name="char" /> <type-mapping type="short" name="integer" /> <type-mapping type="boolean" name="bool" /> <type-mapping type="java.util.Date" name="timestamp" /> <type-mapping type="" name="oid" /> <disallowed-field name="position" /> <disallowed-field name="parent" /> <disallowed-field name="password" /> <disallowed-field name="username" /> <disallowed-field name="date" /> <disallowed-field name="order" /> <disallowed-field named="abort" /> <disallowed-field named="analyze" /> <disallowed-field named="binary" /> <disallowed-field named="cluster" /> <disallowed-field named="constraint" /> <disallowed-field named="copy" /> <disallowed-field named="do" /> <disallowed-field named="explain" /> <disallowed-field named="extend" /> <disallowed-field named="listen" /> <disallowed-field named="load" /> <disallowed-field named="lock" /> <disallowed-field named="move" /> <disallowed-field named="new" /> <disallowed-field named="none" /> <disallowed-field named="notify" /> <disallowed-field named="offset" /> <disallowed-field named="reset" /> <disallowed-field named="setof" /> <disallowed-field named="show" /> <disallowed-field named="transaction" /> <disallowed-field named="unlisten" /> <disallowed-field named="until" /> <disallowed-field named="vacuum" /> <disallowed-field named="verbose" /> </database-scheme>
    3. The file:
      needs to be changed to utilize PostgreSQL as a datasource by adding the following lines to that file:
      <?xml version="1.0"?>
          name="Default data-source"
      With the following substitutions:
      The hostname of the database server.
      The database name.
      The username.
      The password.

    Important Note
    When Orion starts up or interacts with PostgreSQL, it may display an error similar to this:
    SQL error: ERROR: parser: parse error at or near ")"
    This is a known issue and has no affect on applications - disregard this message.

    Orion support is available via the Orion Server: mailing list.
    And also via: Orion Support.

  13. Credits

  14. Many thanks to Ed Wolpert who helped in the construction of this FAQ. Ed is currently working on the PostgreSQL JDBC Driver.

That completes the PostgreSQL Windows Install FAQ. Please contact support with any upgrades or suggestions.
It is worthwhile to spend some time at the PostgreSQL website. The documentation and mailing lists cover topics ranging from general database functionality to SQL usage and techniques.

Terms | Privacy | Copyright Home | Sign Up | Products | Services | Contact Support | Manual | Webmail | Login