Here you can find the source of prepareStatement(Connection conn, String name, String sql)
Parameter | Description |
---|---|
SQLException | an exception |
public static final PreparedStatement prepareStatement(Connection conn, String name, String sql) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; public class Main { /**//from w ww. j ava 2 s . c o m * prepare statements for this connection. Assumes generated keys. * * @throws SQLException **/ public static final PreparedStatement prepareStatement(Connection conn, String name, String sql) throws SQLException { PreparedStatement ps = null; try { ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); } finally { if (ps == null) { System.err.println("Warning: couldn't initialize " + name + " from " + sql); } } // if(false) System.out.println("EXPLAIN EXTENDED " + // sql.replaceAll("\\?", "'?'")+";"); // } catch ( SQLException se ) { // String complaint = "Vetter: Couldn't prepare " + name + " - " + // DBUtils.unchainSqlException(se) + " - " + sql; // logger.severe(complaint); // throw new RuntimeException(complaint); // } return ps; } }