Helma Logo
main list history

Helma and MySQL

This is a short howto for how to configure Helma with MySQL.

MySQL is a popular Open Source Relational Database that is available for all major operating systems and comes preconfigured on many Linux distributions. This HOWTO assumes you have a MySQL server up and running. For information on configuring MySQL please refer to the appropriate documentation.

Helma can use any JDBC compliant driver as datasource, so this document may apply to other database drivers, especially if they are pure Java drivers and do not require native code to be loaded.

Setting up MySQL as Helma datasource is a simple process:

  1. Get a recent MySQL Connector/J JDBC driver from the MySQL site. Previous versions of Helma came with the MySQL driver pre-installed, but we stopped doing so because it was to hard to keep up with new versions, and the driver is not a core component of Helma.
  2. Unpack the Connector/J archive and install the driver by copying the mysql-connector-*.jar file to the lib/ext directory of your Helma installation. Jar files in lib/ext will be automatically added to the Helma classpath, no manual fiddling with the classpath is required.
  3. Add a file called db.properties to the directory of the application in which you wish to use the MySQL datasource

     # Properties of mysql datasource
     mysql.url = jdbc:mysql://localhost/dbname
     mysql.driver = com.mysql.jdbc.Driver
     mysql.user = joe
     mysql.password = secret
    
    In this example, the name of the data source is mysql, but of course you can use any other name by using a different property name prefix. Make sure you specify a valid username/password combination. The JDBC URL may also vary if you want to connect to a MySQL server running on another server or another port than the default port, e.g. jdbc:mysql://foo.bar.com:3456/dbname.

This should be it. After restarting Helma, you should be able to access the MySQL data source using either the helma.Database module or through Helma's Object-Relational Mapping layer.

If you have a problem accessing the MySQL data source make sure the username and password you are using are allowed to connect from the server you're running Helma on. MySQL uses separate authentication settings for connects from the local host an remote hosts, so this is a frequent stumbling block.

For a convenient way to issue SQL statements against a Helma data source have a look at SqlShell.