package testjdbc; import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import javax.sql.PooledConnection; public class Main { private static final String url = "jdbc:mysql://localhost/test"; public static void main(String[] args) throws SQLException { PooledConnection conn = null; PreparedStatement stmt = null; try { MysqlConnectionPoolDataSource pool = new MysqlConnectionPoolDataSource(); pool.setURL(url); pool.setUser("test"); pool.setPassword("test"); conn = pool.getPooledConnection(); stmt = conn.getConnection().prepareStatement("select * from testdb.DATABASE_VERSION;"); ResultSet rs = stmt.executeQuery(); rs.first(); String version = rs.getString(1); System.out.println(version); } catch(SQLException ex) { ex.printStackTrace(); } finally { if (stmt != null) stmt.close(); if (conn != null) conn.close(); } } }