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 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: |
At line 32 removed 1 line. |
Edit database.properties, where you'll change a number of settings: |
At line 30 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=org.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 removed 12 lines. |
;:''Uncomment the db2 settings and comment out the mysql settings'' |
{{{ |
## 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 |
}}} |
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 50 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 79 added 16 lines. |
__NOTE:__ After trying AppFuse on PostgreSQL, I discovered that using Hibernate's ''generator-class="native"'' for my id's failed. This is likely due to the fact that I'm inserting data (using DBUnit) and the sequences get out of wack. I changed all id's to "increment" (example below) and it fixed the problem. This worked on all the databases I tested (MySQL, PostgreSQL and DB2). |
|
[{Java2HtmlPlugin |
|
/** |
* Returns the id. |
* @return String |
* |
* @hibernate.id column="id" |
* generator-class="increment" unsaved-value="null" |
*/ |
public Long getId() { |
return id; |
} |
}] |
|
At line 133 added 4 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.__ |
|
<div style="color: #666"> |
At line 124 changed 1 line. |
test -> admin (usernames and passwords) |
test -> db2admin (usernames and passwords) |
At line 136 changed 1 line. |
{{{ [java] at org.appfuse.persistence.UserDAOHibernate.getUsers(UserDAOHibernate.java:89) |
{{{ [java] at org.appfuse.dao.UserDAOHibernate.getUsers(UserDAOHibernate.java:89) |
At line 166 added 1 line. |
</div> |
At line 176 changed 1 line. |
After [searching on Google|http://tinyurl.com/ys3zm] it appears this is caused by some columns I have that are length="2000". I created a new Buffer Pool with Page Size = 8, and added a new Table Space that used this Buffer Pool. Running "ant db-init" worked after doing this. I suppose if I had a database creation script, this would not be a problem because the Buffer Pool and Table Space sizes would be set properly. |
After [searching on Google|http://tinyurl.com/ys3zm] it appears this is caused by some columns I have that are length="2000". I created a new Buffer Pool with Page Size = 8, and added a new Table Space that used this Buffer Pool. Running "ant db-init" worked after doing this. |
At line 189 removed 2 lines. |
;:''I'm sure if I had a proper database creation script, with proper table spaces sizes (page size = 8), this would be much easier.'' |
|