Example usage for java.sql PreparedStatement setNull

List of usage examples for java.sql PreparedStatement setNull

Introduction

In this page you can find the example usage for java.sql PreparedStatement setNull.

Prototype

void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException;

Source Link

Document

Sets the designated parameter to SQL NULL.

Usage

From source file:org.deegree.sqldialect.oracle.OracleGeometryConverter.java

@Override
public void setParticle(PreparedStatement stmt, Geometry particle, int paramIndex) throws SQLException {
    try {/*  ww w.  jav a 2  s . c  o  m*/
        if (particle == null) {
            stmt.setNull(paramIndex, Types.STRUCT, "MDSYS.SDO_GEOMETRY");
        } else {
            Geometry compatible = getCompatibleGeometry(particle);
            // TODO clarify if this was only a wkt/wkb requirement ?!
            // (background Envelope -> Optimized Rectangles in Oracle are preferred and faster for SDO_RELATE
            // filters )
            //
            // if ( compatible instanceof Envelope ) {
            // compatible = compatible.getConvexHull();
            // }
            OracleConnection ocon = getOracleConnection(stmt.getConnection());
            Object struct = new SDOGeometryConverter().fromGeometry(ocon, isrid, compatible, true);
            stmt.setObject(paramIndex, struct);
        }
    } catch (Throwable t) {
        t.printStackTrace();
        throw new IllegalArgumentException();
    }
}