本文整理汇总了Java中com.mysql.jdbc.SQLError类的典型用法代码示例。如果您正苦于以下问题:Java SQLError类的具体用法?Java SQLError怎么用?Java SQLError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SQLError类属于com.mysql.jdbc包,在下文中一共展示了SQLError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug10630
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* Tests fix for BUG#10630, Statement.getWarnings() fails with NPE if
* statement has been closed.
*/
public void testBug10630() throws Exception {
Connection conn2 = null;
Statement stmt2 = null;
try {
conn2 = getConnectionWithProps((Properties) null);
stmt2 = conn2.createStatement();
conn2.close();
stmt2.getWarnings();
fail("Should've caught an exception here");
} catch (SQLException sqlEx) {
assertEquals(SQLError.SQL_STATE_ILLEGAL_ARGUMENT, sqlEx.getSQLState());
} finally {
if (stmt2 != null) {
stmt2.close();
}
if (conn2 != null) {
conn2.close();
}
}
}
示例2: setShardKey
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setShardKey(String shardKey) throws SQLException {
ensureNoTransactionInProgress();
this.currentConnection = null;
if (shardKey != null) {
if (this.serverGroupName != null) {
throw SQLError.createSQLException("Shard key cannot be provided when server group is chosen directly.", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
null, getExceptionInterceptor(), this);
} else if (this.shardTable == null) {
throw SQLError.createSQLException("Shard key cannot be provided without a shard table.", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, null,
getExceptionInterceptor(), this);
}
// sharded group selection
setCurrentServerGroup(this.shardMapping.getGroupNameForKey(shardKey));
} else if (this.shardTable != null) {
setCurrentServerGroup(this.shardMapping.getGlobalGroupName());
}
this.shardKey = shardKey;
}
示例3: setCurrentServerGroup
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* Change the server group to the given named group.
*/
protected void setCurrentServerGroup(String serverGroupName) throws SQLException {
this.serverGroup = this.fabricConnection.getServerGroup(serverGroupName);
if (this.serverGroup == null) {
throw SQLError.createSQLException("Cannot find server group: `" + serverGroupName + "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, null,
getExceptionInterceptor(), this);
}
// check for any changes that need to be propagated to the entire group
ReplicationConnectionGroup replConnGroup = ReplicationConnectionGroupManager.getConnectionGroup(serverGroupName);
if (replConnGroup != null) {
if (replConnGroupLocks.add(this.serverGroup.getName())) {
try {
syncGroupServersToReplicationConnectionGroup(replConnGroup);
} finally {
replConnGroupLocks.remove(this.serverGroup.getName());
}
}
}
}
示例4: setSavepoint
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* @see Connection#setSavepoint()
*/
public java.sql.Savepoint setSavepoint() throws SQLException {
checkClosed();
if (isInGlobalTx()) {
throw SQLError.createSQLException("Can't set autocommit to 'true' on an XAConnection", SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
}
try {
return this.mc.setSavepoint();
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
示例5: unwrap
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* Returns an object that implements the given interface to allow access to
* non-standard methods, or standard methods not exposed by the proxy. The
* result may be either the object found to implement the interface or a
* proxy for that object. If the receiver implements the interface then that
* is the object. If the receiver is a wrapper and the wrapped object
* implements the interface then that is the object. Otherwise the object is
* the result of calling <code>unwrap</code> recursively on the wrapped
* object. If the receiver is not a wrapper and does not implement the
* interface, then an <code>SQLException</code> is thrown.
*
* @param iface
* A Class defining an interface that the result must implement.
* @return an object that implements the interface. May be a proxy for the
* actual implementing object.
* @throws java.sql.SQLException
* If no object found that implements the interface
* @since 1.6
*/
public synchronized <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException {
try {
if ("java.sql.Connection".equals(iface.getName()) || "java.sql.Wrapper.class".equals(iface.getName())) {
return iface.cast(this);
}
if (unwrappedInterfaces == null) {
unwrappedInterfaces = new HashMap<Class<?>, Object>();
}
Object cachedUnwrapped = unwrappedInterfaces.get(iface);
if (cachedUnwrapped == null) {
cachedUnwrapped = Proxy.newProxyInstance(this.mc.getClass().getClassLoader(), new Class<?>[] { iface },
new ConnectionErrorFiringInvocationHandler(this.mc));
unwrappedInterfaces.put(iface, cachedUnwrapped);
}
return iface.cast(cachedUnwrapped);
} catch (ClassCastException cce) {
throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
}
}
示例6: testBug21267
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* Tests fix for BUG#21267, ParameterMetaData throws NullPointerException
* when prepared SQL actually has a syntax error
*
* @throws Exception
*/
public void testBug21267() throws Exception {
createTable("bug21267", "(`Col1` int(11) NOT NULL,`Col2` varchar(45) default NULL,`Col3` varchar(45) default NULL,PRIMARY KEY (`Col1`))");
this.pstmt = this.conn.prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
this.pstmt.setInt(1, 1);
java.sql.ParameterMetaData psMeta = this.pstmt.getParameterMetaData();
try {
assertEquals(0, psMeta.getParameterType(1));
} catch (SQLException sqlEx) {
assertEquals(SQLError.SQL_STATE_DRIVER_NOT_CAPABLE, sqlEx.getSQLState());
}
this.pstmt.close();
Properties props = new Properties();
props.setProperty("generateSimpleParameterMetadata", "true");
this.pstmt = getConnectionWithProps(props).prepareStatement("SELECT Col1, Col2,Col4 FROM bug21267 WHERE Col1=?");
psMeta = this.pstmt.getParameterMetaData();
assertEquals(Types.VARCHAR, psMeta.getParameterType(1));
}
示例7: setSavepoint
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
/**
* @see Connection#setSavepoint(String)
*/
public java.sql.Savepoint setSavepoint(String arg0) throws SQLException {
checkClosed();
if (isInGlobalTx()) {
throw SQLError.createSQLException("Can't set autocommit to 'true' on an XAConnection", SQLError.SQL_STATE_INVALID_TRANSACTION_TERMINATION,
MysqlErrorNumbers.ER_XA_RMERR, this.exceptionInterceptor);
}
try {
return this.mc.setSavepoint(arg0);
} catch (SQLException sqlException) {
checkAndFireConnectionError(sqlException);
}
return null; // we don't reach this code, compiler can't tell
}
示例8: setBoolean
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setBoolean(int parameterIndex, boolean x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setBoolean(parameterIndex, x);
} else {
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例9: setFetchSize
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setFetchSize(int rows) throws SQLException {
try {
if (this.wrappedStmt != null) {
this.wrappedStmt.setFetchSize(rows);
} else {
throw SQLError.createSQLException("Statement already closed", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例10: getBigDecimal
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
@Deprecated
public BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException {
try {
if (this.wrappedStmt != null) {
return ((CallableStatement) this.wrappedStmt).getBigDecimal(parameterIndex, scale);
}
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
示例11: setBlob
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setBlob(String parameterName, InputStream x, long length) throws SQLException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setBlob(parameterName, x, length);
} else {
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例12: setNull
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setNull(parameterIndex, sqlType, typeName);
} else {
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例13: setRowId
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setRowId(int parameterIndex, RowId x) throws SQLException {
try {
if (this.wrappedStmt != null) {
((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex, x);
} else {
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例14: setBinaryStream
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException {
try {
if (this.wrappedStmt != null) {
((CallableStatement) this.wrappedStmt).setBinaryStream(parameterName, x, length);
} else {
throw SQLError.createSQLException("No operations allowed after statement closed", SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
}
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
}
示例15: executeUpdate
import com.mysql.jdbc.SQLError; //导入依赖的package包/类
public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
try {
if (this.wrappedStmt != null) {
return this.wrappedStmt.executeUpdate(sql, columnIndexes);
}
throw SQLError.createSQLException("Statement already closed", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return -1; // we actually never get here, but the compiler can't figure that out
}