use of org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException in project dbeaver by serge-rider.
the class HANAGeometryValueHandler method bindParameter.
@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
Object geometry = value;
int srid = 0;
if (geometry instanceof DBGeometry) {
srid = ((DBGeometry) geometry).getSRID();
geometry = ((DBGeometry) geometry).getRawValue();
}
if (srid == 0 && paramType instanceof GisAttribute) {
srid = ((GisAttribute) paramType).getAttributeGeometrySRID(session.getProgressMonitor());
}
if (geometry == null) {
statement.setNull(paramIndex, paramType.getTypeID());
} else if (geometry instanceof Geometry) {
Geometry g = (Geometry) geometry;
if (g.getSRID() == 0) {
g.setSRID(srid);
}
try {
statement.setBytes(paramIndex, HANAWKBWriter.write(g, HANAXyzmModeFinder.findXyzmMode(g)));
} catch (HANAWKBWriterException e) {
throw new DBCException(e, session.getExecutionContext());
}
} else {
throw new DBCException("Could not bind the value because the value type is not a known geometry type");
}
}
use of org.jkiss.dbeaver.ext.hana.model.data.wkb.HANAWKBWriterException in project dbeaver by dbeaver.
the class HANAGeometryValueHandler method bindParameter.
@Override
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, int paramIndex, Object value) throws DBCException, SQLException {
Object geometry = value;
int srid = 0;
if (geometry instanceof DBGeometry) {
srid = ((DBGeometry) geometry).getSRID();
geometry = ((DBGeometry) geometry).getRawValue();
}
if (srid == 0 && paramType instanceof GisAttribute) {
srid = ((GisAttribute) paramType).getAttributeGeometrySRID(session.getProgressMonitor());
}
if (geometry == null) {
statement.setNull(paramIndex, paramType.getTypeID());
} else if (geometry instanceof Geometry) {
Geometry g = (Geometry) geometry;
if (g.getSRID() == 0) {
g.setSRID(srid);
}
try {
statement.setBytes(paramIndex, HANAWKBWriter.write(g, HANAXyzmModeFinder.findXyzmMode(g)));
} catch (HANAWKBWriterException e) {
throw new DBCException(e, session.getExecutionContext());
}
} else {
throw new DBCException("Could not bind the value because the value type is not a known geometry type");
}
}
Aggregations