本文整理汇总了Java中oracle.sql.STRUCT类的典型用法代码示例。如果您正苦于以下问题:Java STRUCT类的具体用法?Java STRUCT怎么用?Java STRUCT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
STRUCT类属于oracle.sql包,在下文中一共展示了STRUCT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaToSql
import oracle.sql.STRUCT; //导入依赖的package包/类
/** Methode utilisee si on n'utilise PAS les classes maison "OxygenePresistenceBroker" et "GeOxygeneStatementManager".
* Ceci est a definir dans OJB.properties.
* Inconvenient : on utilise une variable connection statique,
* donc impossible de se connecter a plusieurs bases Oracle simultanement.
* De plus il y a un bug avec OJB : impossible d'ecrire des geometries nulles.
*/
public static Object javaToSql (Object object) {
try {
Geometry sdoGeom = IsoAndSdo.iso2sdoapi(GF,(GM_Object)object);
SDOTemplateFactory sdoTF;
if (CONNECTION instanceof BatchConnection) {// ceci est pour OJB
OracleConnection oConn = (OracleConnection) ((BatchConnection)CONNECTION).getDelegate();
sdoTF = new SDOTemplateFactoryImpl(oConn);
} else
sdoTF = new SDOTemplateFactoryImpl((OracleConnection)CONNECTION);
STRUCT str = SDOGeometry.geometryToSTRUCT(sdoGeom,sdoTF);
return str;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例2: GM_Object2Sdo
import oracle.sql.STRUCT; //导入依赖的package包/类
public static Object GM_Object2Sdo(Object object, Connection conn) {
try {
GeometryFactory gf = OraSpatialManager.getGeometryFactory();
Geometry sdoGeom = IsoAndSdo.iso2sdoapi(gf,(GM_Object)object);
SDOTemplateFactory sdoTF;
if (conn instanceof BatchConnection) {// ceci est pour OJB
OracleConnection oConn = (OracleConnection) ((BatchConnection)conn).getDelegate();
sdoTF = new SDOTemplateFactoryImpl(oConn);
} else
sdoTF = new SDOTemplateFactoryImpl((OracleConnection)conn);
STRUCT str = SDOGeometry.geometryToSTRUCT(sdoGeom,sdoTF);
return str;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例3: convertGeometry
import oracle.sql.STRUCT; //导入依赖的package包/类
@Override
public JdbcChangeValue convertGeometry(String aValue, Connection aConnection) throws SQLException {
if (!(aConnection instanceof OracleConnection)) {
aConnection = aConnection.unwrap(OracleConnection.class);
}
try {
GeometryConverter gc = new GeometryConverter((OracleConnection) aConnection);
JdbcChangeValue jdbcValue = new JdbcChangeValue(null, null, 0, null);
WKTReader reader = new WKTReader();
jdbcValue.value = aValue != null ? gc.toSDO(reader.read(aValue)) : null;
jdbcValue.jdbcType = Types.STRUCT;
jdbcValue.sqlTypeName = "MDSYS.SDO_GEOMETRY";
return jdbcValue;
} catch (ParseException ex) {
throw new SQLException(ex);
}
}
示例4: readGeometry
import oracle.sql.STRUCT; //导入依赖的package包/类
@Override
public String readGeometry(Wrapper aRs, int aColumnIndex, Connection aConnection) throws SQLException {
Object read = aRs instanceof ResultSet ? ((ResultSet) aRs).getObject(aColumnIndex) : ((CallableStatement) aRs).getObject(aColumnIndex);
boolean wasNull = aRs instanceof ResultSet ? ((ResultSet) aRs).wasNull() : ((CallableStatement) aRs).wasNull();
if (wasNull) {
return null;
} else {
if (read instanceof STRUCT) {
STRUCT struct = (STRUCT) read;
GeometryConverter reader = new GeometryConverter(struct.getInternalConnection());
Geometry geometry = reader.asGeometry(struct);
WKTWriter writer = new WKTWriter();
return writer.write(geometry);
} else {
return null;
}
}
}
示例5: registerOutput
import oracle.sql.STRUCT; //导入依赖的package包/类
private void registerOutput(Connection conn, CallableStatement callStmt, CallArgument argument,
List<Out> outputs) throws SQLException {
if (argument == null) {
return;
}
AdapterMapping outputAdapter = getOutputAdapter(argument, outputs);
int argumentIndex = argument.getSequence();
int argumentType = argument.getSqlType();
String argumentTypeName = getArgumentTypeName(outputAdapter, argument.getTypeName());
if (isStructType(argument)) {
argumentType = Types.STRUCT;
callStmt.registerOutParameter(argumentIndex, argumentType, argumentTypeName);
} else if (isArrayOfStructType(argument)) {
argumentType = Types.ARRAY;
callStmt.registerOutParameter(argumentIndex, argumentType, argumentTypeName);
} else {
callStmt.registerOutParameter(argumentIndex, argumentType);
}
}
示例6: createDataMap
import oracle.sql.STRUCT; //导入依赖的package包/类
private Map<String, Object> createDataMap(STRUCT objectStruct, AdapterMapping adapter)
throws SQLException {
Map<String, Object> map = null;
if (objectStruct != null) {
map = new DataMap<String, Object>();
OracleTypeADT oracleTypeADT = (OracleTypeADT) objectStruct.getDescriptor().getPickler();
int numAttributes = oracleTypeADT.getNumAttrs();
Object[] attributeValues = objectStruct.getAttributes();
for (int i = 0; i < numAttributes; i++) {
int attributeIndex = i + 1;
String attributeName = oracleTypeADT.getAttributeName(attributeIndex);
if ((adapter != null) && (adapter.adaptAll() == false)) {
attributeName = getAdapterAttribute(attributeName, adapter);
}
if (attributeName != null) {
Object attributeValue = attributeValues[i];
map.put(attributeName, attributeValue);
}
}
}
return map;
}
示例7: convertToJTSGeometry
import oracle.sql.STRUCT; //导入依赖的package包/类
public Geometry convertToJTSGeometry(ValueMetaInterface vmi, Object obj, Database db) {
if (obj instanceof oracle.sql.STRUCT) {
try {
// Map Oracle's SRID with the EPSG-SRID or take a custom SRS from WKT
int oracle_srid = JGeometry.load((STRUCT)obj).getSRID();
// see bug 2845785; disabled reading of SRS metadata as temporary workaround,
// meanwhile one must assign SRS manually using Set SRS step
// TODO: review everything!
// SRS epsg_srid = convertToEPSG_SRID(oracle_srid, db.getConnection());
SRS epsg_srid = SRS.UNKNOWN;
vmi.setGeometrySRS(epsg_srid);
WKB wkb = new WKB(ByteOrder.BIG_ENDIAN); // Create empty WKB representation
byte[] b = wkb.fromSTRUCT( (STRUCT) obj ); // convert: Object -> STRUCT -> byte[]
Geometry jtsGeom = (new WKBReader()).read(b); // convert: byte[] -> JTS-Geometry
jtsGeom.setSRID(epsg_srid.getSRID()); // set the SRID of the JTS-Geometry
return jtsGeom;
} catch (Exception e) {
LOGGER.logError("GeoKettle", "Conversion from Oracle-geometry failed.");
return null;
}
} else {
LOGGER.logDetailed("GeoKettle", "No Oracle-geometry found to convert.");
return null;
}
}
示例8: convertToObject
import oracle.sql.STRUCT; //导入依赖的package包/类
public Object convertToObject(ValueMetaInterface vmi, Geometry jtsGeom, Database db) {
WKBWriter wkbWriter = new WKBWriter();
byte[] b = wkbWriter.write(jtsGeom);
WKB wkb = new WKB(ByteOrder.BIG_ENDIAN);
try {
// Map the EPSG- (or custom-) SRID with Oracle's SRID.
// TODO: review this, probably has some of the same issues as when reading the SRID
int oracle_srid = convertToDBMS_SRID(vmi.getGeometrySRS(), db.getConnection());
STRUCT oracleStruct = wkb.toSTRUCT(b, db.getConnection()); // convert: byte[] --> STRUCT (using DB connection)
JGeometry oracleGeom = JGeometry.load(oracleStruct); // convert: STRUCT --> JGeometry
oracleGeom.setSRID(oracle_srid); // set the SRID
oracleStruct = JGeometry.store(db.getConnection(), oracleGeom); // convert: JGeometry --> STRUCT (using DB connection)
return oracleStruct;
} catch (Exception e) {
LOGGER.logError("GeoKettle", "Conversion to Oracle-geometry failed.");
return null;
}
}
示例9: insert
import oracle.sql.STRUCT; //导入依赖的package包/类
public void insert(String attributeName, JGeometry geometry, long cityObjectId) throws SQLException {
if (attributeName == null || attributeName.length() == 0)
return;
psGenericAttribute.setString(1, attributeName);
psGenericAttribute.setInt(2, 6);
psGenericAttribute.setNull(3, Types.VARCHAR);
psGenericAttribute.setNull(4, 0);
psGenericAttribute.setNull(5, 0);
psGenericAttribute.setNull(6, Types.VARCHAR);
psGenericAttribute.setNull(7, Types.DATE);
psGenericAttribute.setLong(9, cityObjectId);
STRUCT obj = SyncJGeometry.syncStore(geometry, batchConn);
psGenericAttribute.setObject(8, obj);
psGenericAttribute.addBatch();
if (++batchCounter == Internal.ORACLE_MAX_BATCH_SIZE)
dbImporterManager.executeBatch(DBImporterEnum.CITYOBJECT_GENERICATTRIB);
}
示例10: readData
import oracle.sql.STRUCT; //导入依赖的package包/类
public List<O2MSyncEventLog> readData(Array oraArray) throws SQLException {
List<O2MSyncEventLog> eventLogList = null;
Object[] eventLogArr = (Object[]) oraArray.getArray();
if (eventLogArr != null && eventLogArr.length > 0) {
eventLogList = new ArrayList<O2MSyncEventLog>();
O2MSyncEventLog eventLog = null;
for (int i = 0; i < eventLogArr.length; i++) {
eventLog = new O2MSyncEventLog();
STRUCT attrArrStruct = (STRUCT) eventLogArr[i];
Object [] attrArr = attrArrStruct.getAttributes();
eventLog.setLogId(new ObjectId());
eventLog.setEventId(String.valueOf(attrArr[0]).trim());
eventLog.setOperation(String.valueOf(attrArr[1]));
java.sql.Timestamp crOn = (java.sql.Timestamp) attrArr[2];
if (crOn != null) {
eventLog.setCrOn(new Date(crOn.getTime()));
} else {
eventLog.setCrOn(new Date());
}
ARRAY oraFilters = (ARRAY) attrArr[6];
Object[] filterStructArr = (Object[]) oraFilters.getOracleArray();
if (filterStructArr != null && filterStructArr.length > 0) {
List<O2MSyncEventInfo> filterList = new ArrayList<O2MSyncEventInfo>();
O2MSyncEventInfo filter = null;
for (int j = 0 ; j < filterStructArr.length; j++) {
STRUCT filterAttrArrStruct = (STRUCT) filterStructArr[j];
Object[] filterAttrArr = filterAttrArrStruct.getAttributes();
filter = new O2MSyncEventInfo();
filter.setTableName(String.valueOf(filterAttrArr[0]).trim());
filter.setColumnName(String.valueOf(filterAttrArr[1]).trim());
filter.setColumnValue(String.valueOf(filterAttrArr[2]));
filterList.add(filter);
}
eventLog.setEventFilters(filterList);
}
eventLogList.add(eventLog);
}
}
return eventLogList;
}
示例11: sqlToJava
import oracle.sql.STRUCT; //导入依赖的package包/类
public static Object sqlToJava (Object object) {
try {
Geometry sdoGeom = SDOGeometry.STRUCTtoGeometry((STRUCT)object,GF,SRM);
GM_Object isoGeom = IsoAndSdo.sdoapi2iso(sdoGeom);
return isoGeom;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例12: Sdo2GM_Object
import oracle.sql.STRUCT; //导入依赖的package包/类
public static Object Sdo2GM_Object(Object object) {
try {
GeometryFactory gf = OraSpatialManager.getGeometryFactory();
SRManager srm = OraSpatialManager.getSpatialReferenceManager();
Geometry sdoGeom = SDOGeometry.STRUCTtoGeometry((STRUCT)object,gf,srm);
GM_Object isoGeom = IsoAndSdo.sdoapi2iso(sdoGeom);
return isoGeom;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例13: executeGeometry
import oracle.sql.STRUCT; //导入依赖的package包/类
/** 1 seul objet geometrique passe en parametre - renvoie une geometrie */
private static GM_Object executeGeometry(Geodatabase data, GM_Object isoGeom, String query) {
// ceci sera le result
GM_Object result = null;
try {
// initialise la connection a Oracle
Connection conn = data.getConnection();
// vide la table TEMP_REQUETE
String update = "DELETE FROM TEMP_REQUETE";
PreparedStatement ps = conn.prepareStatement(update);
ps.executeUpdate();
ps.close();
// convertit isoGeom en type sdoapi, et l'ecrit dans la table TEMP_REQUETE
STRUCT str = (STRUCT) GeometryConvertor.GM_Object2Sdo(isoGeom, conn);
update = "INSERT INTO TEMP_REQUETE VALUES (0,?)";
ps = conn.prepareStatement(update);
ps.setObject(1, str);
ps.executeUpdate();
ps.close();
// execute la requete
ps = conn.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next())
result = (GM_Object)(GeometryConvertor.Sdo2GM_Object (rs.getObject(1)));
rs.close();
ps.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
示例14: getTypeDescriptor
import oracle.sql.STRUCT; //导入依赖的package包/类
private TypeDescriptor getTypeDescriptor(Connection nativeConn, int dataType, String dataTypeName)
throws SQLException {
if (dataType == Types.STRUCT) {
StructDescriptor structDescriptor = StructDescriptor.createDescriptor(dataTypeName, nativeConn);
return structDescriptor;
}
if (dataType == Types.ARRAY) {
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(dataTypeName, nativeConn);
return arrayDescriptor;
}
return null;
}
示例15: convertListOfCellsToOracleArray
import oracle.sql.STRUCT; //导入依赖的package包/类
private static ARRAY convertListOfCellsToOracleArray(final List<CellDefinition> cellDefinitions) throws SQLException {
final StructDescriptor resultStruct = StructDescriptor.createDescriptor("T_ER_CELL_DEFINITION", connection);
final ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("TABLE_OF_ER_CELL_DEFINITIONS", connection);
final STRUCT[] rv = new STRUCT[cellDefinitions.size()];
int i=0;
for(CellDefinition cellDefinition : cellDefinitions)
rv[i++] = new STRUCT(resultStruct, connection, cellDefinition.toSQLStructObject());
return new ARRAY(arrayDesc, connection, rv);
}