Here you can find the source of prepareStatement(Connection conn, Map psMap, String key, String sql)
public static PreparedStatement prepareStatement(Connection conn, Map psMap, String key, String sql) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Map; public class Main { public static PreparedStatement prepareStatement(Connection conn, Map psMap, String key, String sql) throws SQLException { Object[] obj = (Object[]) psMap.get(key); if (obj == null) { obj = new Object[] { null, null }; psMap.put(key, obj);//from w ww . ja v a 2 s . c om } String lastSql = (String) obj[0]; PreparedStatement ps = (PreparedStatement) obj[1]; if (!sql.equals(lastSql)) { if (ps != null) ps.close(); obj[0] = sql; obj[1] = ps = conn.prepareStatement(sql); } return ps; } }