All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jpattern.orm.datasource.PreparedStatementWrapper Maven / Gradle / Ivy

package com.jpattern.orm.datasource;

import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.Date;
import java.sql.NClob;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.Ref;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;

/**
 * 
 * @author cinafr
 *
 */
public class PreparedStatementWrapper implements PreparedStatement, IPreparedStatement {

	private final PreparedStatement preparedStatement;
	private final IConnection conn;

	PreparedStatementWrapper(PreparedStatement preparedStatement, IConnection conn) {
		this.preparedStatement = preparedStatement;
		this.conn = conn;
	}
	
	
	public int executeUpdate(String sql) throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeUpdate(sql);
	}

	public int executeUpdate() throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeUpdate();
	}
	
	public boolean execute() throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.execute();
	}

	public boolean execute(String sql) throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.execute(sql);
	}
	
	public int[] executeBatch() throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeBatch();
	}
	
	public int executeUpdate(String sql, int autoGeneratedKeys)
			throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeUpdate(sql, autoGeneratedKeys);
	}

	public int executeUpdate(String sql, int[] columnIndexes)
			throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeUpdate(sql, columnIndexes);
	}
	
	public int executeUpdate(String sql, String[] columnNames)
			throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.executeUpdate(sql, columnNames);
	}

	public boolean execute(String sql, int autoGeneratedKeys)
			throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.execute(sql, autoGeneratedKeys);
	}
	
	public boolean execute(String sql, String[] columnNames)
			throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.execute(sql, columnNames);
	}
	
	public boolean execute(String sql, int[] columnIndexes) throws SQLException {
		conn.setReadOnly(false);
		return preparedStatement.execute(sql, columnIndexes);
	}
	
	
	public ResultSet executeQuery(String sql) throws SQLException {
		return preparedStatement.executeQuery(sql);
	}

	public  T unwrap(Class iface) throws SQLException {
		return preparedStatement.unwrap(iface);
	}

	public ResultSet executeQuery() throws SQLException {
		return preparedStatement.executeQuery();
	}

	public boolean isWrapperFor(Class iface) throws SQLException {
		return preparedStatement.isWrapperFor(iface);
	}
	
	public void close() throws SQLException {
		preparedStatement.close();
	}

	public void setNull(int parameterIndex, int sqlType) throws SQLException {
		preparedStatement.setNull(parameterIndex, sqlType);
	}

	public int getMaxFieldSize() throws SQLException {
		return preparedStatement.getMaxFieldSize();
	}

	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
		preparedStatement.setBoolean(parameterIndex, x);
	}

	public void setMaxFieldSize(int max) throws SQLException {
		preparedStatement.setMaxFieldSize(max);
	}

	public void setByte(int parameterIndex, byte x) throws SQLException {
		preparedStatement.setByte(parameterIndex, x);
	}

	public void setShort(int parameterIndex, short x) throws SQLException {
		preparedStatement.setShort(parameterIndex, x);
	}

	public int getMaxRows() throws SQLException {
		return preparedStatement.getMaxRows();
	}

	public void setInt(int parameterIndex, int x) throws SQLException {
		preparedStatement.setInt(parameterIndex, x);
	}

	public void setMaxRows(int max) throws SQLException {
		preparedStatement.setMaxRows(max);
	}

	public void setLong(int parameterIndex, long x) throws SQLException {
		preparedStatement.setLong(parameterIndex, x);
	}

	public void setEscapeProcessing(boolean enable) throws SQLException {
		preparedStatement.setEscapeProcessing(enable);
	}

	public void setFloat(int parameterIndex, float x) throws SQLException {
		preparedStatement.setFloat(parameterIndex, x);
	}

	public int getQueryTimeout() throws SQLException {
		return preparedStatement.getQueryTimeout();
	}

	public void setDouble(int parameterIndex, double x) throws SQLException {
		preparedStatement.setDouble(parameterIndex, x);
	}

	public void setQueryTimeout(int seconds) throws SQLException {
		preparedStatement.setQueryTimeout(seconds);
	}

	public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException {
		preparedStatement.setBigDecimal(parameterIndex, x);
	}

	public void cancel() throws SQLException {
		preparedStatement.cancel();
	}

	public void setString(int parameterIndex, String x) throws SQLException {
		preparedStatement.setString(parameterIndex, x);
	}

	public SQLWarning getWarnings() throws SQLException {
		return preparedStatement.getWarnings();
	}

	public void setBytes(int parameterIndex, byte[] x) throws SQLException {
		preparedStatement.setBytes(parameterIndex, x);
	}

	public void clearWarnings() throws SQLException {
		preparedStatement.clearWarnings();
	}

	public void setDate(int parameterIndex, Date x) throws SQLException {
		preparedStatement.setDate(parameterIndex, x);
	}

	public void setCursorName(String name) throws SQLException {
		preparedStatement.setCursorName(name);
	}

	public void setTime(int parameterIndex, Time x) throws SQLException {
		preparedStatement.setTime(parameterIndex, x);
	}

	public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException {
		preparedStatement.setTimestamp(parameterIndex, x);
	}

	public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException {
		preparedStatement.setAsciiStream(parameterIndex, x, length);
	}

	public ResultSet getResultSet() throws SQLException {
		return preparedStatement.getResultSet();
	}

	@Deprecated
	public void setUnicodeStream(int parameterIndex, InputStream x, int length)
			throws SQLException {
		preparedStatement.setUnicodeStream(parameterIndex, x, length);
	}

	public int getUpdateCount() throws SQLException {
		return preparedStatement.getUpdateCount();
	}

	public boolean getMoreResults() throws SQLException {
		return preparedStatement.getMoreResults();
	}

	public void setBinaryStream(int parameterIndex, InputStream x, int length)
			throws SQLException {
		preparedStatement.setBinaryStream(parameterIndex, x, length);
	}

	public void setFetchDirection(int direction) throws SQLException {
		preparedStatement.setFetchDirection(direction);
	}

	public void clearParameters() throws SQLException {
		preparedStatement.clearParameters();
	}

	public int getFetchDirection() throws SQLException {
		return preparedStatement.getFetchDirection();
	}

	public void setObject(int parameterIndex, Object x, int targetSqlType)
			throws SQLException {
		preparedStatement.setObject(parameterIndex, x, targetSqlType);
	}

	public void setFetchSize(int rows) throws SQLException {
		preparedStatement.setFetchSize(rows);
	}

	public int getFetchSize() throws SQLException {
		return preparedStatement.getFetchSize();
	}

	public void setObject(int parameterIndex, Object x) throws SQLException {
		preparedStatement.setObject(parameterIndex, x);
	}

	public int getResultSetConcurrency() throws SQLException {
		return preparedStatement.getResultSetConcurrency();
	}

	public int getResultSetType() throws SQLException {
		return preparedStatement.getResultSetType();
	}

	public void addBatch(String sql) throws SQLException {
		preparedStatement.addBatch(sql);
	}

	public void clearBatch() throws SQLException {
		preparedStatement.clearBatch();
	}

	public void addBatch() throws SQLException {
		preparedStatement.addBatch();
	}

	public void setCharacterStream(int parameterIndex, Reader reader, int length)
			throws SQLException {
		preparedStatement.setCharacterStream(parameterIndex, reader, length);
	}

	public void setRef(int parameterIndex, Ref x) throws SQLException {
		preparedStatement.setRef(parameterIndex, x);
	}

	public Connection getConnection() throws SQLException {
		return preparedStatement.getConnection();
	}

	public void setBlob(int parameterIndex, Blob x) throws SQLException {
		preparedStatement.setBlob(parameterIndex, x);
	}

	public void setClob(int parameterIndex, Clob x) throws SQLException {
		preparedStatement.setClob(parameterIndex, x);
	}

	public boolean getMoreResults(int current) throws SQLException {
		return preparedStatement.getMoreResults(current);
	}

	public void setArray(int parameterIndex, Array x) throws SQLException {
		preparedStatement.setArray(parameterIndex, x);
	}

	public ResultSetMetaData getMetaData() throws SQLException {
		return preparedStatement.getMetaData();
	}

	public ResultSet getGeneratedKeys() throws SQLException {
		return preparedStatement.getGeneratedKeys();
	}

	public void setDate(int parameterIndex, Date x, Calendar cal)
			throws SQLException {
		preparedStatement.setDate(parameterIndex, x, cal);
	}

	public void setTime(int parameterIndex, Time x, Calendar cal)
			throws SQLException {
		preparedStatement.setTime(parameterIndex, x, cal);
	}
	
	public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
			throws SQLException {
		preparedStatement.setTimestamp(parameterIndex, x, cal);
	}

	public void setNull(int parameterIndex, int sqlType, String typeName)
			throws SQLException {
		preparedStatement.setNull(parameterIndex, sqlType, typeName);
	}



	public void setURL(int parameterIndex, URL x) throws SQLException {
		preparedStatement.setURL(parameterIndex, x);
	}

	public ParameterMetaData getParameterMetaData() throws SQLException {
		return preparedStatement.getParameterMetaData();
	}

	public void setRowId(int parameterIndex, RowId x) throws SQLException {
		preparedStatement.setRowId(parameterIndex, x);
	}

	public void setNString(int parameterIndex, String value)
			throws SQLException {
		preparedStatement.setNString(parameterIndex, value);
	}

	public void setNCharacterStream(int parameterIndex, Reader value,
			long length) throws SQLException {
		preparedStatement.setNCharacterStream(parameterIndex, value, length);
	}

	public void setNClob(int parameterIndex, NClob value) throws SQLException {
		preparedStatement.setNClob(parameterIndex, value);
	}

	public void setClob(int parameterIndex, Reader reader, long length)
			throws SQLException {
		preparedStatement.setClob(parameterIndex, reader, length);
	}

	public int getResultSetHoldability() throws SQLException {
		return preparedStatement.getResultSetHoldability();
	}

	public void setBlob(int parameterIndex, InputStream inputStream, long length)
			throws SQLException {
		preparedStatement.setBlob(parameterIndex, inputStream, length);
	}

	public boolean isClosed() throws SQLException {
		return preparedStatement.isClosed();
	}

	public void setPoolable(boolean poolable) throws SQLException {
		preparedStatement.setPoolable(poolable);
	}

	public void setNClob(int parameterIndex, Reader reader, long length)
			throws SQLException {
		preparedStatement.setNClob(parameterIndex, reader, length);
	}

	public boolean isPoolable() throws SQLException {
		return preparedStatement.isPoolable();
	}

	public void setSQLXML(int parameterIndex, SQLXML xmlObject)
			throws SQLException {
		preparedStatement.setSQLXML(parameterIndex, xmlObject);
	}

	public void setObject(int parameterIndex, Object x, int targetSqlType,
			int scaleOrLength) throws SQLException {
		preparedStatement.setObject(parameterIndex, x, targetSqlType,
				scaleOrLength);
	}

	public void setAsciiStream(int parameterIndex, InputStream x, long length)
			throws SQLException {
		preparedStatement.setAsciiStream(parameterIndex, x, length);
	}

	public void setBinaryStream(int parameterIndex, InputStream x, long length)
			throws SQLException {
		preparedStatement.setBinaryStream(parameterIndex, x, length);
	}

	public void setCharacterStream(int parameterIndex, Reader reader,
			long length) throws SQLException {
		preparedStatement.setCharacterStream(parameterIndex, reader, length);
	}

	public void setAsciiStream(int parameterIndex, InputStream x)
			throws SQLException {
		preparedStatement.setAsciiStream(parameterIndex, x);
	}

	public void setBinaryStream(int parameterIndex, InputStream x)
			throws SQLException {
		preparedStatement.setBinaryStream(parameterIndex, x);
	}

	public void setCharacterStream(int parameterIndex, Reader reader)
			throws SQLException {
		preparedStatement.setCharacterStream(parameterIndex, reader);
	}

	public void setNCharacterStream(int parameterIndex, Reader value)
			throws SQLException {
		preparedStatement.setNCharacterStream(parameterIndex, value);
	}

	public void setClob(int parameterIndex, Reader reader) throws SQLException {
		preparedStatement.setClob(parameterIndex, reader);
	}

	public void setBlob(int parameterIndex, InputStream inputStream)
			throws SQLException {
		preparedStatement.setBlob(parameterIndex, inputStream);
	}

	public void setNClob(int parameterIndex, Reader reader) throws SQLException {
		preparedStatement.setNClob(parameterIndex, reader);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy