This topic explains how to configure a MySQL database as an
external data source.
The MySQL Driver
LabKey Server requires the MySQL driver (called "MySQL Connector/J" in the MySQL documentation) to connect to MySQL databases. The LabKey Windows installer and manual install steps will copy the MySQL driver JAR file (mysql.jar) to your Tomcat installation, in <tomcat-home>/lib, making it available to your LabKey Server.
Detailed documentation about the driver is available at:
MySQL Connector/J Developer Guide.
Configure the MySQL Data Source
Add a <Resource> element, to your installation's
labkey.xml configuration file. Use the configuration template below as a starting point.
Replace USERNAME and PASSWORD with the correct credentials.
If you are running LabKey Server against a remote installation of MySQL, change the url attribute to point to the remote server.
<Resource name="jdbc/mySqlDataSource" auth="Container"
type="javax.sql.DataSource"
username="USERNAME"
password="PASSWORD"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/?autoReconnect=true&
useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull"
maxActive="15"
maxIdle="7"
useInformationSchema="true"
accessToUnderlyingConnectionAllowed="true"
validationQuery="/* ping */"/>
Note: the "zeroDataTimeBehavior=convertToNull" parameter on the url above converts MySQL's special representation of invalid dates ("00-00-0000") into null. See the MySQL documentation for other options.
Define a New Schema
Now define a new schema from the MySQL data source. For details see
Set Up an External Schema.
Related Topics
com.mysql.jdbc.Driver Documentation