How to verify that data source is valid and configured properly?
<p>In application start up , I am loading data source as shown below code -</p>

<pre><code>@Bean(name = "dataSource")
public DataSource getDataSource() {
    ComboPooledDataSource dataSource = new ComboPooledDataSource ();
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    dataSource.setUrl("jdbc:mysql://localhost:3306/usersdb");
    dataSource.setUsername("root");
    dataSource.setPassword("secret");
    return dataSource;
}
</code></pre>

<p>So here I would like to verify that whether the data source loaded properly, 
One possible way could be <strong>datasource.getConnection()</strong> before return but here I have to create  unnecessary connection object which is having some high cost.</p>

<p>Please help me to find a way to verify that data source has been instantiated properly. I have heard something about validate query but not sure how it would work. please suggest. </p>