Helma logo
helma.org » Home > docs > howtos > Configuring Helma with MySQL

Configuring Helma with 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
    
    Make sure to replace the dbname with the name of the MySQL database you want to use, and 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.

    In this example, the name of the data source is mysql, but of course you can use any other name instead.
This should be it. After restarting Helma, you should be able to access the MySQL data source using either the global getDBConnection() function or through Helma's object relational mapping.

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.


Up: Deployment Guides
Previous: Configuring Helma with log4j

... comment


Page last modified on 2003-11-27 17:32 by czv

 
liberte, Tuesday, 8. June 2004, 06:21
Does Helma create the database or do I
One thing I am confused about is whether I am supposed to set up a database with MySQL named dbname, or whatever. It might be the case that Helma could create the database, if the specified user can create databases. The same question applies later regarding tables: Will Helma create tables if they do not already exist, or must I do that with some dbadmin tool?

What if I have an independently created database containing tables of existing data that I want to interface with. Can I use this database with Helma?

... link  

 
liberte, Saturday, 12. June 2004, 07:51
You must create your own database and tables
Stefan says:

"Helma does all the persistence-stuff for you - it stores and retrieves the objects from the DB but doesn't offer anything for creating the DB automatically With the information currently provided in the type.properties files it's not posssible to create a db-table because information about column-types and indexes is missing completely"

Seems to me that the additional information could be added, and Helma could provide a simple mysql admin interface via the web. sqlShell is a step in that direction already.

... link  


... comment