【MySQL】mysql连接池( 五 )


public class DbcpApp {public static void main(String[] args) {MyDBCP dbcp = MyDBCP.getDbcp();PreparedStatement pre = null;Connection connection = null;try {connection = dbcp.getConnection();String sql = "select * from student where SID > ?";pre = connection.prepareStatement(sql);pre.setString(1, "01");ResultSet resultSet = pre.executeQuery();while (resultSet.next()) {//hashnext next-1System.out.println("SID:" + resultSet.getString(1) +"SName:" + resultSet.getString(2)+ "SAge:" + resultSet.getString(3)+ "SSex:" + resultSet.getString(4));}} catch (Exception e) {e.printStackTrace();} finally {try {pre.close();connection.close();//将连接归还给链接池} catch (SQLException e) {e.printStackTrace();}}}}
7、上面三种连接池的区别