Mule + SQLite (aka hello database)
Mule + SQLite (aka hello database)
I'm quite new to the MULE platform so for a sampler project, I wanted to access a simple lightweight RDBMS, and so looked to take advantage of the generic Database connector and configure it to use a JDBC driver for SQLite. There are plenty of great tutorials out there on the connector in general but I did see a few people asking specifically about SQLite and no direct answers so hopefully, the following helps somebody.You will need.
The JDBC Driver - available here bitbucket.org/xerial/sqlite-jdbc/downloads/
The SQLite executables (are a nice to have) www.sqlite.org/download.html
An SQLite database file (either roll your own or use the sample here)
Key configuration steps
- Make sure that the JDBC driver is on your classpath
- Copy the jar to "src/main/resources"
- Right-click on the jar, select "Build Path" > "Add to Build Path"
- Add the Database connector as usual, and add the 'Generic Database Connector; global type
- Generic Database Connector configuration information
- URL: will be jdbc:sqlite:[path to your database file] e.g. jdbc:sqlite:c:/sqlite/doctors.db
- Driver Class Name: org.sqlite.JDBC
Samples
Sample Mule project github.com/ndbeal/jack-and-mare/blob/master/sqlite-hello.zip.Sample database (as configured to be installed in c:\sqlite\) github.com/ndbeal/jack-and-mare/blob/master/doctors.db.
General Debugging
Symptom:Getting a "java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database" on execution, but 'Test Connection' is fine.
Suggestion:
Check if you have a relative path.
I encountered this a lot playing with relative paths, they are in theory supported (and a quick google confirms as such) but where they are relative to is clearly different than other resources in the mule container. Perhaps a kind commenter will have the time to expand on this.
awesome !. i have been wrangling around this problem for couple of days. your blog just helped me within minutes. thank you so much.
ReplyDeleteThanks for sharing this information, this is useful to me...
ReplyDeleteMulesoft Online Training india
Mulesoft Online Training in Hyderabad