Spatial DataBlade
JAVA API v8.21

com.ibm.spatial.io
Class IfxSQLData

java.lang.Object
  extended by com.ibm.spatial.io.IfxSQLData
All Implemented Interfaces:
com.informix.jdbc.UDTSQLData, java.sql.SQLData

public class IfxSQLData
extends java.lang.Object
implements com.informix.jdbc.UDTSQLData

This class implements the interface com.informix.jdbc.UDTSQLData specified by Informix JDBC drivers for accessing user-defined SQL types.

Applications must call enableTypes before reading geometry objects from an IBM Informix Spatial database, in order to enable mapping of database user defined types for a JDBC connection. Until this method is called, geometry objects cannot be sent to or received from the server using the JDBC connection.

Note: this API was tested with the IBM Informix JDBC driver version 2.21.JC2.


Constructor Summary
IfxSQLData()
          Constructor
 
Method Summary
static java.util.Map enableTypes(java.sql.Connection conn)
          Must be called to enable the spatial type mapping for a JDBC connection.
 GeometryReader getReader()
          Returns a copy of the reader used by this object to read and decode geometry data from an SQL stream.
 java.lang.Object getSQLDataObject()
          Returns the desired java object
 java.lang.String getSQLTypeName()
          Returns the fully-qualified name of the SQL user-defined type that this object represents.
 GeometryWriter getWriter()
          Returns a copy of the writer used by this object to encode and write geometry data to an SQL stream.
 void readSQL(java.sql.SQLInput stream, java.lang.String type)
          Reads data from the database and creates an appropriate geometry object to hold it.
 IfxSQLData setObject(java.lang.Object data)
          Sets the object to be written to the database server.
 void writeSQL(java.sql.SQLOutput stream)
          Writes this object to the given SQL data stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IfxSQLData

public IfxSQLData()
Constructor

Method Detail

getSQLDataObject

public java.lang.Object getSQLDataObject()
                                  throws java.sql.SQLException
Returns the desired java object

Specified by:
getSQLDataObject in interface com.informix.jdbc.UDTSQLData
Returns:
the actual java object
Throws:
java.sql.SQLException - if the internal data object is null

getSQLTypeName

public java.lang.String getSQLTypeName()
Returns the fully-qualified name of the SQL user-defined type that this object represents. This method is called by the JDBC driver to get the name of the UDT instance that is being mapped to this instance of SQLData.

Specified by:
getSQLTypeName in interface java.sql.SQLData
Returns:
the type name that was passed to the method readSql when this object was constructed and populated //throws SQLException if there is a database access error

readSQL

public void readSQL(java.sql.SQLInput stream,
                    java.lang.String type)
             throws java.sql.SQLException
Reads data from the database and creates an appropriate geometry object to hold it.

Specified by:
readSQL in interface java.sql.SQLData
Parameters:
stream - an SQLInput object from which to read the data
type - the SQL type name of the value on the data stream
Throws:
java.sql.SQLException - if there is a read error

writeSQL

public void writeSQL(java.sql.SQLOutput stream)
              throws java.sql.SQLException
Writes this object to the given SQL data stream.

Specified by:
writeSQL in interface java.sql.SQLData
Throws:
java.sql.SQLException - if there is a write error

setObject

public IfxSQLData setObject(java.lang.Object data)
Sets the object to be written to the database server. This method should be called before setting this object to a prepared statement.

Parameters:
data - the actual object to be written to the database server
Returns:
this object

getReader

public GeometryReader getReader()
Returns a copy of the reader used by this object to read and decode geometry data from an SQL stream.

If no reader is already cached, this method will get an appropriate reader from the SpatialManager and return a copy of it.

Returns:
a copy of the SQL reader used by this object

getWriter

public GeometryWriter getWriter()
Returns a copy of the writer used by this object to encode and write geometry data to an SQL stream.

If no writer is already cached, this method will get an appropriate writer from the SpatialManager and return a copy of it.

Returns:
a copy of the SQL writer used by this object

enableTypes

public static final java.util.Map enableTypes(java.sql.Connection conn)
                                       throws SpatialException
Must be called to enable the spatial type mapping for a JDBC connection. Until this method is called, Geometries cannot be sent to or received from the server using the JDBC connection.

Parameters:
conn - The JDBC connection for which spatial types are to be enabled.
Returns:
the custom type map associated with the Connection object
Throws:
SpatialException - if an error occurs

Spatial DataBlade
JAVA API v8.21


Licensed Materials - Property of IBM
Copyright IBM Corp. 2002, 2012 All Rights Reserved.