本文整理汇总了Java中com.mysql.jdbc.NotUpdatable类的典型用法代码示例。如果您正苦于以下问题:Java NotUpdatable类的具体用法?Java NotUpdatable怎么用?Java NotUpdatable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotUpdatable类属于com.mysql.jdbc包,在下文中一共展示了NotUpdatable类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMultiKeyTable
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
/**
* Tests that the driver does not let you update result sets that come from
* queries that haven't selected all primary keys
*
* @throws SQLException
* if an error occurs
*/
public void testMultiKeyTable() throws SQLException {
this.stmt.executeUpdate("DROP TABLE IF EXISTS MULTI_UPDATABLE");
this.stmt.executeUpdate("CREATE TABLE MULTI_UPDATABLE (field1 int NOT NULL, field2 int NOT NULL, PRIMARY KEY (field1, field2))");
Statement scrollableStmt = null;
try {
scrollableStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
this.rs = scrollableStmt.executeQuery("SELECT field1 FROM MULTI_UPDATABLE");
try {
this.rs.moveToInsertRow();
fail("ResultSet.moveToInsertRow() should not succeed on query that does not select all primary keys");
} catch (NotUpdatable noUpdate) {
// ignore
}
} finally {
if (scrollableStmt != null) {
try {
scrollableStmt.close();
} catch (SQLException sqlEx) {
// ignore
}
}
this.stmt.executeUpdate("DROP TABLE IF EXISTS MULTI_UPDATABLE");
}
}
示例2: testBogusTable
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
/**
* Tests that the driver does not let you update result sets that come from
* tables that don't have primary keys
*
* @throws SQLException
* if an error occurs
*/
public void testBogusTable() throws SQLException {
this.stmt.executeUpdate("DROP TABLE IF EXISTS BOGUS_UPDATABLE");
this.stmt.executeUpdate("CREATE TABLE BOGUS_UPDATABLE (field1 int)");
Statement scrollableStmt = null;
try {
scrollableStmt = this.conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
this.rs = scrollableStmt.executeQuery("SELECT * FROM BOGUS_UPDATABLE");
try {
this.rs.moveToInsertRow();
fail("ResultSet.moveToInsertRow() should not succeed on non-updatable table");
} catch (NotUpdatable noUpdate) {
// ignore
}
} finally {
if (scrollableStmt != null) {
try {
scrollableStmt.close();
} catch (SQLException sqlEx) {
// ignore
}
}
this.stmt.executeUpdate("DROP TABLE IF EXISTS BOGUS_UPDATABLE");
}
}
示例3: testNonUpdResultSetUpdateObject
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
/**
* Test for ResultSet.updateObject(), non-updatable ResultSet behaviour.
*/
public void testNonUpdResultSetUpdateObject() throws Exception {
this.rs = this.stmt.executeQuery("SELECT 'testResultSetUpdateObject' AS test");
final ResultSet rsTmp = this.rs;
assertThrows(NotUpdatable.class, "Result Set not updatable.*", new Callable<Void>() {
@Override
public Void call() throws Exception {
rsTmp.updateObject(1, rsTmp.toString(), JDBCType.VARCHAR);
return null;
}
});
assertThrows(NotUpdatable.class, "Result Set not updatable.*", new Callable<Void>() {
@Override
public Void call() throws Exception {
rsTmp.updateObject(1, rsTmp.toString(), JDBCType.VARCHAR, 10);
return null;
}
});
assertThrows(NotUpdatable.class, "Result Set not updatable.*", new Callable<Void>() {
@Override
public Void call() throws Exception {
rsTmp.updateObject("test", rsTmp.toString(), JDBCType.VARCHAR);
return null;
}
});
assertThrows(NotUpdatable.class, "Result Set not updatable.*", new Callable<Void>() {
@Override
public Void call() throws Exception {
rsTmp.updateObject("test", rsTmp.toString(), JDBCType.VARCHAR, 10);
return null;
}
});
}
示例4: updateNClob
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
throw new NotUpdatable();
}
示例5: updateBlob
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
throw new NotUpdatable();
}
示例6: updateRowId
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateRowId(int columnIndex, RowId x) throws SQLException {
throw new NotUpdatable();
}
示例7: updateCharacterStream
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
throw new NotUpdatable();
}
示例8: updateBinaryStream
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
throw new NotUpdatable();
}
示例9: updateNCharacterStream
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
/**
* JDBC 4.0 Update a column with a character stream value. The updateXXX()
* methods are used to update column values in the current row, or the
* insert row. The updateXXX() methods do not update the underlying
* database, instead the updateRow() or insertRow() methods are called to
* update the database.
*
* @param columnIndex
* the first column is 1, the second is 2, ...
* @param x
* the new column value
* @param length
* the length of the stream
*
* @exception SQLException
* if a database-access error occurs
* @throws NotUpdatable
*/
public void updateNCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
throw new NotUpdatable();
}
示例10: updateNCharacterStream
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
throw new NotUpdatable();
}
示例11: updateAsciiStream
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
throw new NotUpdatable();
}
示例12: updateBlob
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
throw new NotUpdatable();
}
示例13: updateClob
import com.mysql.jdbc.NotUpdatable; //导入依赖的package包/类
public void updateClob(int columnIndex, Reader reader) throws SQLException {
throw new NotUpdatable();
}