userpreparedstatement.java
来自「RESIN 3.2 最新源码」· Java 代码 · 共 811 行 · 第 1/2 页
JAVA
811 行
/* * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved * * This file is part of Resin(R) Open Source * * Each copy or derived work must preserve the copyright notice and this * notice unmodified. * * Resin Open Source is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Resin Open Source is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty * of NON-INFRINGEMENT. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with Resin Open Source; if not, write to the * * Free Software Foundation, Inc. * 59 Temple Place, Suite 330 * Boston, MA 02111-1307 USA * * @author Scott Ferguson */package com.caucho.sql;import com.caucho.log.Log;import com.caucho.util.L10N;import java.io.InputStream;import java.io.Reader;import java.math.BigDecimal;import java.net.URL;import java.sql.*;import java.util.Calendar;import java.util.logging.Logger;/** * User-view of prepared statements */public class UserPreparedStatement extends UserStatement implements PreparedStatement { protected final static Logger log = Log.open(UserPreparedStatement.class); protected static L10N L = new L10N(UserPreparedStatement.class); protected PreparedStatement _pstmt; protected PreparedStatementCacheItem _cacheItem; private boolean _isClosed; UserPreparedStatement(UserConnection conn, PreparedStatement pStmt, PreparedStatementCacheItem cacheItem) { super(conn, pStmt); _pstmt = pStmt; _cacheItem = cacheItem; if (pStmt == null) throw new NullPointerException(); } UserPreparedStatement(UserConnection conn, PreparedStatement pStmt) { this(conn, pStmt, null); } /** * Returns the underlying statement. */ public PreparedStatement getPreparedStatement() { return _pstmt; } /** * Executes the prepared statement's query. */ public ResultSet executeQuery() throws SQLException { try { return _pstmt.executeQuery(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Executes the prepared statement's sql as an update */ public int executeUpdate() throws SQLException { try { return _pstmt.executeUpdate(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Executes the prepared statement's sql as an update or query */ public boolean execute() throws SQLException { try { return _pstmt.execute(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Adds the statement as a batch. */ public void addBatch() throws SQLException { try { _pstmt.addBatch(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Clears the statement's parameters. */ public void clearParameters() throws SQLException { try { _pstmt.clearParameters(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Returns the result metadata. */ public ResultSetMetaData getMetaData() throws SQLException { try { return _pstmt.getMetaData(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Returns the prepared statement's meta data. */ public ParameterMetaData getParameterMetaData() throws SQLException { try { return _pstmt.getParameterMetaData(); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a null. */ public void setNull(int parameterIndex, int sqlType) throws SQLException { try { _pstmt.setNull(parameterIndex, sqlType); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a null. */ public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { try { _pstmt.setNull(parameterIndex, sqlType, typeName); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a boolean. */ public void setBoolean(int index, boolean value) throws SQLException { try { _pstmt.setBoolean(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a byte. */ public void setByte(int index, byte value) throws SQLException { try { _pstmt.setByte(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a short. */ public void setShort(int index, short value) throws SQLException { try { _pstmt.setShort(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as an int */ public void setInt(int index, int value) throws SQLException { try { _pstmt.setInt(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a long */ public void setLong(int index, long value) throws SQLException { try { _pstmt.setLong(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a float */ public void setFloat(int index, float value) throws SQLException { try { _pstmt.setFloat(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a double */ public void setDouble(int index, double value) throws SQLException { try { _pstmt.setDouble(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a BigDecimal */ public void setBigDecimal(int index, BigDecimal value) throws SQLException { try { _pstmt.setBigDecimal(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a string */ public void setString(int index, String value) throws SQLException { try { _pstmt.setString(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /** * Sets the parameter as a byte array. */ public void setBytes(int index, byte []value) throws SQLException { try { _pstmt.setBytes(index, value); } catch (RuntimeException e) { killPool(); throw e; } catch (SQLException e) { killPool(); throw e; } } /**
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?