Java SQL PreparedStatement prepareStatement(Connection conn, String name, String sql)

Here you can find the source of prepareStatement(Connection conn, String name, String sql)

Description

prepare statements for this connection.

License

Open Source License

Exception

Parameter Description
SQLException an exception

Declaration

public static final PreparedStatement prepareStatement(Connection conn, String name, String sql)
        throws SQLException 

Method Source Code

//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;
    }
}

Related

  1. LockRow(PreparedStatement pstmt, String tablename, boolean exclusiveMode)
  2. logPreparedStatement(PreparedStatement p)
  3. prepareStatement( Connection conn, String query, List params)
  4. prepareStatement(Connection con,String sql,Object...params)
  5. prepareStatement(Connection conn, Map psMap, String key, String sql)
  6. prepareStatement(Connection conn, String sql)
  7. prepareStatement(Connection conn, String sql, boolean isCallable)
  8. prepareStatement(Connection conn, String sql, Object... values)
  9. prepareStatement(Connection connection, String line)