tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ingmar Lötzsch <>
Subject Re: PostgreSQL vs MySQL with Tomcat
Date Fri, 16 Jan 2009 08:44:44 GMT
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

	description text NOT NULL

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

INSERT INTO foo (description) VALUES ('foo');


SELECT currval('foo_id_seq');


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')
	INSERT INTO foo (id, description)

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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message