Some comments (and answers to Christopher and Rusty) on PostgreSQL:

In 2004 our team decided to use PostgreSQL instead of the well-known
MySQL (current version 4). The main reasons where

- real referential integrity
- real transactions
- support for UTF-8 enoding
- better compliance with the SQL standard

> The one warning I can think of with PostgreSQL is that you have to use
> schemas; you either have to set the schema after you connect, and I
> think I couldn't figure out how to do that with jdbc, or you specify it
> as part of every table name; "create table schema_name.table_name ...;
> select whatever from schema_name.table_name;".  Schemas are quite cool,
> so don't take this as a criticism.

This isn't true. You can (and perhaps should) always omit the schema.
The default schema "public" is used in this case. You can execute

CREATE TABLE foo
(
        id serial NOT NULL PRIMARY KEY,
        description text NOT NULL
);

>NOTICE:  CREATE TABLE will create implicit sequence "foo_id_seq" for
serial column "foo.id"
>NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"foo_pkey" for table "foo"

INSERT INTO foo (description) VALUES ('foo');
SELECT * FROM foo;

>1;"foo"

SELECT currval('foo_id_seq');

>1

In the persistende layer we have switched from JDBC to iBATIS.

There you have the SQL statements organized in XML files. One approach
for INSERT is

<insert id="insert" parameterClass="com.asci.Foo" >
        <selectKey keyProperty="id" resultClass="int" type="pre">
                SELECT nextval('foo_id_seq')
        </selectKey>
        INSERT INTO foo (id, description)
        VALUES
        (
                #id:INTEGER#,
                #description:VARCHAR#
        )
</insert>

In the DAO implementation you have

public Integer insert(Foo foo)
{
        Integer id = (Integer) getSqlMapClientTemplate().insert("foo.insert", 
foo);
        return id;
}

or simply

public void insert(Foo foo)
{
        getSqlMapClientTemplate().insert("foo.insert", foo);
}

After the call the Foo instance contains the generated ID in both cases.

We didn't need much support for PostgreSQL. The documentation is
comprehensive. The installation under Windows is easy. The installation
unter UNIX systems can have some difficulties.

Ingmar

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to