*/
public void writeSchemaColumn(String schema)
throws SQLException {
// always use special clob handling when dict has max embedded size;
// for some reason optimizing for string length causes errors
DBDictionary dict = _conf.getDBDictionaryInstance();
boolean embedded = dict.maxEmbeddedClobSize == -1;
String update;
if (embedded)
update = "UPDATE " + dict.getFullName(_pkColumn.getTable(), false)
+ " SET " + _schemaColumn + " = ? WHERE " + _pkColumn + " = ?";
else
update = "SELECT " + _schemaColumn + " FROM "
+ dict.getFullName(_pkColumn.getTable(), false)
+ " WHERE " + _pkColumn + " = ?";
Connection conn = getConnection();
PreparedStatement stmnt = null;
ResultSet rs = null;
boolean wasAuto = true;
try {
// if embedded we want autocommit true, else false
wasAuto = conn.getAutoCommit();
if (wasAuto != embedded)
conn.setAutoCommit(embedded);
if (embedded) {
stmnt = conn.prepareStatement(update);
if (schema == null)
dict.setNull(stmnt, 1, _schemaColumn.getType(),
_schemaColumn);
else if (_schemaColumn.getType() == Types.CLOB)
dict.setClobString(stmnt, 1, schema, _schemaColumn);
else
dict.setString(stmnt, 1, schema, _schemaColumn);
dict.setInt(stmnt, 2, 1, _pkColumn);
stmnt.executeUpdate();
} else {
stmnt = conn.prepareStatement(update,
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
dict.setInt(stmnt, 1, 1, _pkColumn);
rs = stmnt.executeQuery();
rs.next();
dict.putString(rs.getClob(1), schema);
conn.commit();
}
}
finally {
if (rs != null)