use of org.jkiss.dbeaver.model.impl.jdbc.data.JDBCReference in project dbeaver by serge-rider.
the class JDBCReferenceValueHandler method bindParameter.
@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
JDBCReference reference = (JDBCReference) value;
statement.setRef(paramIndex, reference.getValue());
}
use of org.jkiss.dbeaver.model.impl.jdbc.data.JDBCReference in project dbeaver by serge-rider.
the class JDBCReferenceValueHandler method getValueFromObject.
@Override
public JDBCReference getValueFromObject(@NotNull DBCSession session, @NotNull DBSTypedObject type, Object object, boolean copy) throws DBCException {
String typeName;
try {
if (object instanceof Ref) {
typeName = ((Ref) object).getBaseTypeName();
} else {
typeName = type.getTypeName();
}
} catch (SQLException e) {
throw new DBCException(e, session.getDataSource());
}
DBSDataType dataType = null;
try {
dataType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), typeName);
} catch (DBException e) {
log.error("Error resolving data type '" + typeName + "'", e);
}
if (dataType == null) {
dataType = new JDBCDataType(session.getDataSource().getContainer(), Types.REF, typeName, "Synthetic struct type for reference '" + typeName + "'", false, false, 0, 0, 0);
}
if (object == null) {
return new JDBCReference(dataType, null);
} else if (object instanceof JDBCReference) {
return (JDBCReference) object;
} else if (object instanceof Ref) {
return new JDBCReference(dataType, (Ref) object);
} else {
throw new DBCException("Unsupported struct type: " + object.getClass().getName());
}
}
Aggregations