Changed Database.java logic

We will open database connection directly when starting application.
Connection with database will be disconnected when application closes.