Monday, February 25, 2013

Error with starting OpenMRS - "Unable to get a connection to the database"

This blog post will be about a very primary error on starting and running OpenMRS medical record system, in which i did my gsoc project and where i am still contributing whenever i get a time (yes i still love openmrs!). This is more like a note to myself.

I recently started to use a new laptop, therefore i moved all my openmrs repositories, .m2 repository and .OpenMRS directories into the new machine, as my intention was saving the time that will be taken to build everything from scratch again. However when i tried to run OpenMRS in the new machine, after installing and setting up mysql server, it returned the following error.

java.lang.RuntimeException: Error occurred while trying to get the updates needed for the database.
Unable to get a connection to the database.  Please check your openmrs 
runtime properties file and make sure you have the correct 
connection.username and
connection.password set ...
.................................................................................
.................................................................................
Caused by: java.sql.SQLException: Access denied for user 'openmrs_user'@'localhost' (using password: YES)


 Although i have worked with the project over an year now, i was also first confused on why the webapp can not be started. But then i realized the fix.

This is simply because when we start the web app from a previous implementation it still uses some of the configuration from its past installation. 
If you go to "webapp" folder in the 'openmrs_home' repository, there is a file called "openmrs-runtime.properties" where there is previous configuration data (usernames, passwords etc.) still present. Now simply delete this file from /home/USER_NAME/.OpenMRS folder if it is present there. Then delete this file from the 'webapp' folder and start again using 'mvn jetty:run'. No more errors, You are good to go now  :) :)