At line 3 changed 1 line. |
;:''This howto assumed you've already installed DB2 and your DBA username/password combination is admin/admin.'' |
;:''This howto assumed you've already installed DB2 and your DBA username/password combination is db2admin/db2admin.'' |
At line 5 added 2 lines. |
__January 16, 2004 UPDATE:__ I greatly simplified this process in AppFuse and altered this HowTo accordingly. This reflects the latest code in CVS and updates that will be in 1.3. |
|
At line 27 changed 4 lines. |
Edit properties.xml and change the database.jar to be db2.jar: |
{{{ |
<property name="database.jar" location="${db2.jar}"/> |
}}} |
Edit your build.properties file to reflect your new database of choice. MySQL settings are the defaults specified in properties.xml. Here is a sample for DB2, followed by one for PostgreSQL: |
At line 32 removed 1 line. |
Edit database.properties, where you'll change a number of settings: |
At line 32 added 1 line. |
database.jar=${db2.jar} |
At line 35 changed 1 line. |
database.name=jdbc:db2:appfuse |
#database.name=appfuse |
database.host=localhost |
#database URL for creating other databases (not used with db2) |
database.admin.url=jdbc:${database.type}://${database.host}/db2 |
database.admin.username=db2admin |
database.admin.password=db2admin |
|
hibernate.dialect=net.sf.hibernate.dialect.DB2Dialect |
database.driver_class=COM.ibm.db2.jdbc.net.DB2Driver |
database.url=jdbc:${database.type}://${database.host}/${database.name} |
database.username=db2admin |
database.password=db2admin |
At line 37 changed 1 line. |
;:''Uncomment the db2 settings and comment out the mysql settings'' |
|
__PostgreSQL:___ |
At line 39 changed 9 lines. |
## DB2 |
hibernate.dialect net.sf.hibernate.dialect.DB2Dialect |
hibernate.connection.driver_class = COM.ibm.db2.jdbc.app.DB2Driver |
hibernate.connection.url = jdbc:db2:apptrack |
hibernate.connection.username = admin |
hibernate.connection.password = admin |
hibernate.connection.pool_size = 20 |
hibernate.statement_cache.size = 6 |
hibernate.show_sql = false |
database.jar=${postgresql.jar} |
database.type=postgresql |
database.name=appfuse |
database.host=localhost |
#database URL for creating other databases |
database.admin.url=jdbc:${database.type}://${database.host}/template1 |
database.admin.username=postgres |
database.admin.password=postgres |
|
hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect |
database.driver_class=org.postgresql.Driver |
database.url=jdbc:${database.type}://${database.host}/${database.name} |
database.username=postgres |
database.password=postgres |
At line 50 changed 1 line. |
I haven't yet figured out how to create the ''appfuse'' database using straight SQL, but I did find it to be fairly easy using DB2's "Command Line Processor". Just open the application and type "create db appfuse" - and wait for about 2 minutes. |
You can use the database.properties.reference file for other database's settings. |
At line 52 changed 1 line. |
At this point, running "ant setup-db" will fail because we have no db2-create.sql in metadata/sql. Since the database is already created, I just used "ant db-init". Now onto the errors and ways I fixed them. |
I was unable to create databases ''on-the-fly'' (using JDBC) on PostgresSQL (transaction error) or on DB2. Therefore, I changed the "db-create" target to only attempt to do this for MySQL. If you're not using MySQL, you don't need to specify the database.admin.* properties since they won't be used. See the DB2 Sample Script[#6] for creating a new database in the ''Command Line Processor''. |
At line 70 added 2 lines. |
Now let's looks at tweaks I had to make to AppFuse to make ''easy database switching'' a reality. |
|
At line 72 changed 2 lines. |
* @hibernate.property |
* column="email" not-null="false" |
* @hibernate.property column="email" not-null="false" |
At line 137 added 3 lines. |
|
__Below is the old way to do it. In 1.3, I modified the ''tomcat-context.xml'' and ''hibernate.cfg.xml'' to get the database-specific attributes replaced at build-time. This eliminates the process below. I'll leave it in here in case you're on an older version of AppFuse.__ |
|