use of org.jkiss.dbeaver.model.impl.jdbc.JDBCArrayImpl in project dbeaver by dbeaver.
the class JDBCCollection method getArrayValue.
public Array getArrayValue() throws DBCException {
Object[] attrs = new Object[contents.length];
for (int i = 0; i < contents.length; i++) {
Object attr = contents[i];
if (attr instanceof DBDValue) {
attr = ((DBDValue) attr).getRawValue();
}
attrs[i] = attr;
}
final DBSDataType dataType = getComponentType();
try (DBCSession session = DBUtils.openUtilSession(new VoidProgressMonitor(), dataType.getDataSource(), "Create JDBC array")) {
if (session instanceof Connection) {
return ((Connection) session).createArrayOf(dataType.getTypeName(), attrs);
} else {
return new JDBCArrayImpl(dataType.getTypeName(), dataType.getTypeID(), attrs);
}
} catch (Throwable e) {
throw new DBCException("Error creating struct", e);
}
}
use of org.jkiss.dbeaver.model.impl.jdbc.JDBCArrayImpl in project dbeaver by serge-rider.
the class JDBCCollection method getArrayValue.
public Array getArrayValue() throws DBCException {
if (contents == null) {
return null;
}
Object[] attrs = new Object[contents.length];
for (int i = 0; i < contents.length; i++) {
Object attr = contents[i];
if (attr instanceof DBDValue) {
attr = ((DBDValue) attr).getRawValue();
}
attrs[i] = attr;
}
final DBSDataType dataType = getComponentType();
try (DBCSession session = DBUtils.openUtilSession(new VoidProgressMonitor(), dataType, "Create JDBC array")) {
if (session instanceof Connection) {
String typeName = DBUtils.getObjectFullName(dataType, DBPEvaluationContext.DML);
return ((Connection) session).createArrayOf(typeName, attrs);
} else {
return new JDBCArrayImpl(dataType.getTypeName(), dataType.getTypeID(), attrs);
}
} catch (Throwable e) {
throw new DBCException("Error creating struct", e);
}
}
Aggregations