os.write(((String) value).getBytes(STRING_ENCODING));
}
}
public void writeValue(PreparedStatement st, Object value, int index) throws SQLException {
HibernateInitializer hi = CoreServices.lookup().getHibernateInitializer();
if (hi.isPostgresDatabase()) {
st.setString(index, ((String) value));
} else if (hi.isH2Database()) {
st.setString(index, ((String) value));
} else if (hi.isMySQLDatabase()) {
try {
st.setBytes(index, value == null ? null : ((String) value).getBytes(STRING_ENCODING));
} catch (UnsupportedEncodingException e) {
log.error("Error: ", e);
}
} else if (hi.isSQLServerDatabase()) {
st.setString(index, (String) value);
} else {
throw new IllegalArgumentException("Unknown database name: " + hi.getDatabaseName());
}
}
});
}