Search in sources :

Example 1 with DBDComposite

use of org.jkiss.dbeaver.model.data.DBDComposite in project dbeaver by serge-rider.

the class PostgreStructValueHandler method bindParameter.

@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
    if (value == null) {
        statement.setNull(paramIndex, Types.STRUCT);
    } else if (value instanceof DBDComposite) {
        DBDComposite struct = (DBDComposite) value;
        if (struct.isNull()) {
            statement.setNull(paramIndex, Types.STRUCT);
        } else if (struct instanceof JDBCComposite) {
            final Object[] values = ((JDBCComposite) struct).getValues();
            final String string = PostgreUtils.generateObjectString(values);
            statement.setObject(paramIndex, string, Types.OTHER);
        }
    } else {
        throw new DBCException("Struct parameter type '" + value.getClass().getName() + "' not supported");
    }
}
Also used : DBDComposite(org.jkiss.dbeaver.model.data.DBDComposite) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject) DBCException(org.jkiss.dbeaver.model.exec.DBCException) JDBCComposite(org.jkiss.dbeaver.model.impl.jdbc.data.JDBCComposite)

Aggregations

DBDComposite (org.jkiss.dbeaver.model.data.DBDComposite)1 DBCException (org.jkiss.dbeaver.model.exec.DBCException)1 JDBCComposite (org.jkiss.dbeaver.model.impl.jdbc.data.JDBCComposite)1 DBSTypedObject (org.jkiss.dbeaver.model.struct.DBSTypedObject)1