You define the database parameters in two configuration files underneath your konakart installation directory at:
webapps\konakart\WEB-INF\classes\konakart.properties and webapps\konakartadmin\WEB-INF\classes\konakartadmin.properties
(Therefore, the default on Windows will be at C:\Program Files\KonaKart\webapps\konakart\WEB-INF\classes\konakart.properties).
Inside these files you will find: (the url parameter is broken into two lines for readability only - you should keep it on one line)
# -----------------------------------------------------------------------------------
# D A T A B A S E P R O P E R T I E S
# Database Connection Parameters Set by Installer on 20-Jan-2009
# -----------------------------------------------------------------------------------
torque.applicationRoot = .
torque.database.default = store1
torque.database.store1.adapter = mysql
torque.dsfactory.store1.connection.driver = com.mysql.jdbc.Driver
torque.dsfactory.store1.connection.url =
jdbc:mysql://localhost:3306/store1?zeroDateTimeBehavior=convertToNull
torque.dsfactory.store1.connection.user = fruit
torque.dsfactory.store1.connection.password = secret
-------------------------------------------------------------------------------------
Leave the torque.database.default equal to store1.
You need to set the five parameters appropriate for your environment:
If you wish you can encrypt the database credentials in the KonaKart properties files by using the CreatePassword utility that is provided in the Enterprise Extensions.
You can obtain usage information for the utility by issuing the "-?" parameter as follows:
@blackburn:~/konakart/utils/createPassword: ./createPassword.sh -?
==================================================================================================
KonaKart Create Password Utility
==================================================================================================
Usage: CreatePassword
-f properties-file - the properties file where the results
will be written
-k - the key of the property to encrypt
-p new-value - the new-value to encrypt (typically,
this will be the username or password)
[-en file encoding] - file encoding (default is ISO-8859-1)
[-ce console encoding] - console encoding (default is utf-8)
[-d] - outputs debug information
[-?] - shows this usage information
A ReadMe.txt file is provided in the createPassword directory with instructions on how to use the utility.
After running the utility you end up with an encrypted password in the specified properties along with an associated encryption key.
KonaKart itself has been modified to recognise and decrypt these encrypted passwords by using the associated encryption keys.
If you create the encrypted passwords for copying into another properties file elsewhere, always remember that the encrypted database password needs its associated encryption key - so remember to copy both properties! These associated encryption key values are written on the line following the property itself so they are easy to locate.
If you specify the "-p new-value" parameter the utility will encrypt the specified "new-value". If you do not specify the "-p new-value" parameter at all, the utility will encrypt the current value of the property.
Note that it is also possible to encrypt the database username in exactly the same way as the password. KonaKart will also handle encrypted usernames in the properties files.
It is also possible to define your data source using JNDI. (For various optional configurations not covered here please refer to the Torque Database Configuration documentation on the Apache site.)
In this example Torque is configured to create a JNDI Data Source and deploy it into JNDI:
You would modify your konakart.properties files by commenting out the connection properties used by the default SharedPoolDataSourceFactory factory and replace them as follows:
torque.dsfactory.store1.factory = org.apache.torque.dsfactory.JndiDataSourceFactory
torque.dsfactory.store1.jndi.path = jdbc/konakart
torque.dsfactory.store1.jndi.ttl = 60000
torque.dsfactory.store1.datasource.classname = org.apache.commons.dbcp.BasicDataSource
torque.database.store1.adapter = mysql
torque.dsfactory.store1.jndi.java.naming.factory.initial = \
org.apache.naming.java.javaURLContextFactory
torque.dsfactory.store1.datasource.driverClassName = com.mysql.jdbc.Driver
torque.dsfactory.store1.datasource.url = \
jdbc:mysql://localhost:3306/store1?zeroDateTimeBehavior=convertToNull
torque.dsfactory.store1.datasource.username = fruit
torque.dsfactory.store1.datasource.password = secret
#For JNDI you also need to comment out the following line (as it has been replaced above:
#torque.dsfactory.store1.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
For the database definition for the BIRT reporting engine you need to leave the original connection properties either in a separate properties file or in konakartadmin.properties as follows:
# Leave these for the BIRT reports
torque.dsfactory.store1.connection.driver = com.mysql.jdbc.Driver
torque.dsfactory.store1.connection.url = \
jdbc:mysql://localhost:3306/store1?zeroDateTimeBehavior=convertToNull
torque.dsfactory.store1.connection.user = fruit
torque.dsfactory.store1.connection.password = secret
Note that if you chose to use a separate file, remember to add that file name to the "var dbPropsFile" definition in the "...\webapps\birtviewer\reports\lib\konakart.rptlibrary" file.
In addition to the settings above, you have to set the validationQuery for DB2 and Oracle slightly differently to the others, as follows. This section is defined just below the database parameter definitions in the two properties files (konakart.properties and konakartadmin.properties):
# The SQL query that will be used to validate connections from this pool before # returning them to the caller. If specified, this query MUST be an SQL SELECT # statement that returns at least one row. # Recommended settings: # for MySQL/PostgreSQL/MS SQL use: SELECT 1 # for Oracle use: SELECT 1 from dual # for DB2 use: SELECT 1 FROM sysibm.sysdummy1 torque.dsfactory.store1.pool.validationQuery=SELECT 1 #torque.dsfactory.store2.pool.validationQuery=SELECT 1 -------------------------------------------------------------------
Note that the SQL that is optionally run at installation time uses the "DROP TABLE IF EXISTS TABLE-NAME;" command. This works fine for PostgreSQL 8.2 and above (which support "IF EXISTS") but not for earlier versions.
This is only a problem during the installation process; KonaKart performs well on versions of PostgreSQL prior to 8.2. To workaround this problem, for example for PostgreSQL 8.1, you will have to edit the database/konakart_demo.sql file and remove all the "DROP TABLE" commands then run this SQL manually. In addition to modifying the "IF EXISTS" syntax you will also have to add SQL statements to create sequences for all the SERIAL primary keys. For example, for the counter table, which is created like this:
CREATE TABLE counter ( counter_id SERIAL, startdate char(8), counter integer, PRIMARY KEY (counter_id) );
You have to create the SEQUENCEs with these conventions:
CREATE SEQUENCE <table>_<SERIAL column>_seq
for example:
.. for the counter_id column in the counter table above, you need to create a SRQUENCE like this:
CREATE SEQUENCE counter_counter_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;
Another, preferable, alternative is to update to the latest version of PostgreSQL and run the standard GUI installation and have all the data loaded by the installer.
Note that the SQL that is optionally run at installation time uses the "DROP TABLE IF EXISTS" syntax. This works fine for MySQL 5 and above, but not on MySQL 4.1.
This is only a problem during the installation process; KonaKart performs well on MySQL 4.1 but you have to modify the konakat_demo.sql file and run it yourself manually. You have to edit the database/konakart_demo.sql file and remove all the "DROP TABLE" commands then run this SQL manually. After successfully running this SQL you will be able to run KonaKart with MySQL 4.1.