-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
264 additions
and
23 deletions.
There are no files selected for viewing
245 changes: 245 additions & 0 deletions
245
...ngdang/ddframe/rdb/sharding/jdbc/adapter/AbstractMasterSlavePreparedStatementAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
/* | ||
* Copyright 1999-2015 dangdang.com. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* </p> | ||
*/ | ||
|
||
package com.dangdang.ddframe.rdb.sharding.jdbc.adapter; | ||
|
||
import com.dangdang.ddframe.rdb.sharding.jdbc.unsupported.AbstractUnsupportedOperationPreparedStatement; | ||
|
||
import java.io.InputStream; | ||
import java.io.Reader; | ||
import java.math.BigDecimal; | ||
import java.net.URL; | ||
import java.sql.Blob; | ||
import java.sql.Clob; | ||
import java.sql.Date; | ||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
import java.sql.SQLXML; | ||
import java.sql.Time; | ||
import java.sql.Timestamp; | ||
import java.util.Calendar; | ||
|
||
/** | ||
* Master-slave adapter for {@code PreparedStatement}. | ||
* | ||
* @author zhangliang | ||
*/ | ||
public abstract class AbstractMasterSlavePreparedStatementAdapter extends AbstractUnsupportedOperationPreparedStatement { | ||
|
||
@Override | ||
public final void setNull(final int parameterIndex, final int sqlType) throws SQLException { | ||
getTargetStatement().setNull(parameterIndex, sqlType); | ||
} | ||
|
||
@Override | ||
public final void setNull(final int parameterIndex, final int sqlType, final String typeName) throws SQLException { | ||
getTargetStatement().setNull(parameterIndex, sqlType, typeName); | ||
} | ||
|
||
@Override | ||
public final void setBoolean(final int parameterIndex, final boolean x) throws SQLException { | ||
getTargetStatement().setBoolean(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setByte(final int parameterIndex, final byte x) throws SQLException { | ||
getTargetStatement().setByte(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setShort(final int parameterIndex, final short x) throws SQLException { | ||
getTargetStatement().setShort(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setInt(final int parameterIndex, final int x) throws SQLException { | ||
getTargetStatement().setInt(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setLong(final int parameterIndex, final long x) throws SQLException { | ||
getTargetStatement().setLong(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setFloat(final int parameterIndex, final float x) throws SQLException { | ||
getTargetStatement().setFloat(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setDouble(final int parameterIndex, final double x) throws SQLException { | ||
getTargetStatement().setDouble(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setString(final int parameterIndex, final String x) throws SQLException { | ||
getTargetStatement().setString(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setBigDecimal(final int parameterIndex, final BigDecimal x) throws SQLException { | ||
getTargetStatement().setBigDecimal(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setDate(final int parameterIndex, final Date x) throws SQLException { | ||
getTargetStatement().setDate(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setDate(final int parameterIndex, final Date x, final Calendar cal) throws SQLException { | ||
getTargetStatement().setDate(parameterIndex, x, cal); | ||
} | ||
|
||
@Override | ||
public final void setTime(final int parameterIndex, final Time x) throws SQLException { | ||
getTargetStatement().setTime(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setTime(final int parameterIndex, final Time x, final Calendar cal) throws SQLException { | ||
getTargetStatement().setTime(parameterIndex, x, cal); | ||
} | ||
|
||
@Override | ||
public final void setTimestamp(final int parameterIndex, final Timestamp x) throws SQLException { | ||
getTargetStatement().setTimestamp(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setTimestamp(final int parameterIndex, final Timestamp x, final Calendar cal) throws SQLException { | ||
getTargetStatement().setTimestamp(parameterIndex, x, cal); | ||
} | ||
|
||
@Override | ||
public final void setBytes(final int parameterIndex, final byte[] x) throws SQLException { | ||
getTargetStatement().setBytes(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setBlob(final int parameterIndex, final Blob x) throws SQLException { | ||
getTargetStatement().setBlob(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setBlob(final int parameterIndex, final InputStream x) throws SQLException { | ||
getTargetStatement().setBlob(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setBlob(final int parameterIndex, final InputStream x, final long length) throws SQLException { | ||
getTargetStatement().setBlob(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setClob(final int parameterIndex, final Clob x) throws SQLException { | ||
getTargetStatement().setClob(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setClob(final int parameterIndex, final Reader x) throws SQLException { | ||
getTargetStatement().setClob(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setClob(final int parameterIndex, final Reader x, final long length) throws SQLException { | ||
getTargetStatement().setClob(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setAsciiStream(final int parameterIndex, final InputStream x) throws SQLException { | ||
getTargetStatement().setAsciiStream(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setAsciiStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { | ||
getTargetStatement().setAsciiStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setAsciiStream(final int parameterIndex, final InputStream x, final long length) throws SQLException { | ||
getTargetStatement().setAsciiStream(parameterIndex, x, length); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@Override | ||
public final void setUnicodeStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { | ||
getTargetStatement().setUnicodeStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setBinaryStream(final int parameterIndex, final InputStream x) throws SQLException { | ||
getTargetStatement().setBinaryStream(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setBinaryStream(final int parameterIndex, final InputStream x, final int length) throws SQLException { | ||
getTargetStatement().setBinaryStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setBinaryStream(final int parameterIndex, final InputStream x, final long length) throws SQLException { | ||
getTargetStatement().setBinaryStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setCharacterStream(final int parameterIndex, final Reader x) throws SQLException { | ||
getTargetStatement().setCharacterStream(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public final void setCharacterStream(final int parameterIndex, final Reader x, final int length) throws SQLException { | ||
getTargetStatement().setCharacterStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public final void setCharacterStream(final int parameterIndex, final Reader x, final long length) throws SQLException { | ||
getTargetStatement().setCharacterStream(parameterIndex, x, length); | ||
} | ||
|
||
@Override | ||
public void setSQLXML(final int parameterIndex, final SQLXML x) throws SQLException { | ||
getTargetStatement().setSQLXML(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public void setURL(final int parameterIndex, final URL x) throws SQLException { | ||
getTargetStatement().setURL(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public void setObject(final int parameterIndex, final Object x) throws SQLException { | ||
getTargetStatement().setObject(parameterIndex, x); | ||
} | ||
|
||
@Override | ||
public void setObject(final int parameterIndex, final Object x, final int targetSqlType) throws SQLException { | ||
getTargetStatement().setObject(parameterIndex, x, targetSqlType); | ||
} | ||
|
||
@Override | ||
public void setObject(final int parameterIndex, final Object x, final int targetSqlType, final int scaleOrLength) throws SQLException { | ||
getTargetStatement().setObject(parameterIndex, x, targetSqlType, scaleOrLength); | ||
} | ||
|
||
@Override | ||
public final void clearParameters() throws SQLException { | ||
getTargetStatement().clearParameters(); | ||
} | ||
|
||
protected abstract PreparedStatement getTargetStatement(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters