Hi,
I have an application where the user can define connection parameters like server address, user name and password to the database.
But I'm not able to check if the connection succeeds.
I've written this code but although the connection parameters are invalid no exception is thrown.
Code:
try {
Configuration config = new AnnotationConfiguration().configure();
config.setProperty("hibernate.connection.url", jdbc);
config.setProperty("hibernate.connection.username", user);
config.setProperty("hibernate.connection.password", password);
sessionFactory = config.buildSessionFactory();
sessionFactory.openSession();
} catch(Throwable ex) {
System.error.println("Error");
}
Is there any way how to check the connection before executing SQL query?
Thanks
Jaa