java.sql.PreparedStatement#setSQLXML ( )源码实例Demo

下面列出了java.sql.PreparedStatement#setSQLXML ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void assertSetSQLXML() throws SQLException {
    for (PreparedStatement each : preparedStatements) {
        each.setSQLXML(1, null);
        assertParameter(each, 1, null);
    }
}
 
源代码2 项目: spring-analysis-note   文件: Jdbc4SqlXmlHandler.java
@Override
public void setValue(PreparedStatement ps, int paramIndex) throws SQLException {
	this.xmlObject = ps.getConnection().createSQLXML();
	try {
		provideXml(this.xmlObject);
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex);
	}
	ps.setSQLXML(paramIndex, this.xmlObject);
}
 
@Override
public void setValue(PreparedStatement ps, int paramIndex) throws SQLException {
	this.xmlObject = ps.getConnection().createSQLXML();
	try {
		provideXml(this.xmlObject);
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex);
	}
	ps.setSQLXML(paramIndex, this.xmlObject);
}
 
源代码4 项目: lams   文件: Jdbc4SqlXmlHandler.java
@Override
public void setValue(PreparedStatement ps, int paramIndex) throws SQLException {
	this.xmlObject = ps.getConnection().createSQLXML();
	try {
		provideXml(this.xmlObject);
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex);
	}
	ps.setSQLXML(paramIndex, this.xmlObject);
}
 
@Override
public void setValue(PreparedStatement ps, int paramIndex) throws SQLException {
	this.xmlObject = ps.getConnection().createSQLXML();
	try {
		provideXml(this.xmlObject);
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex);
	}
	ps.setSQLXML(paramIndex, this.xmlObject);
}
 
@Test
public void assertSetSQLXML() throws SQLException {
    for (PreparedStatement each : preparedStatements) {
        each.setSQLXML(1, null);
        assertParameter(each, 1, null);
    }
}
 
源代码7 项目: dalesbred   文件: ArgumentBinder.java
private static void bindXmlDocument(@NotNull PreparedStatement ps, int index, @NotNull Document doc) throws SQLException {
    SQLXML sqlxml = ps.getConnection().createSQLXML();
    // TODO: arrange for the object to be freed after the PreparedStatement has been executed

    sqlxml.setResult(DOMResult.class).setNode(doc);

    ps.setSQLXML(index, sqlxml);
}
 
源代码8 项目: Oceanus   文件: PreparedStatementWrapper.java
@Override
public void setSQLXML(final int parameterIndex, final SQLXML xmlObject)
		throws SQLException {
	ParameterCallback callback = new ParameterCallbackAction(
			parameterIndex, xmlObject) {

		@Override
		public void call(PreparedStatement preparedStatement)
				throws SQLException {
			preparedStatement.setSQLXML(parameterIndex(), xmlObject);
		}
	};
	addParameterCallback(callback);

}
 
@Override
public void set(PreparedStatement target, SQLXML value, int columnIndex, Context context) throws SQLException {
    if (value == null) {
        target.setNull(columnIndex, Types.SQLXML);
    } else {
        target.setSQLXML(columnIndex, value);
    }
}
 
源代码10 项目: effectivejava   文件: Jdbc4SqlXmlHandler.java
@Override
public void setValue(PreparedStatement ps, int paramIndex) throws SQLException {
	this.xmlObject = ps.getConnection().createSQLXML();
	try {
		provideXml(this.xmlObject);
	}
	catch (IOException ex) {
		throw new DataAccessResourceFailureException("Failure encountered while providing XML", ex);
	}
	ps.setSQLXML(paramIndex, this.xmlObject);
}
 
源代码11 项目: Quicksql   文件: ResultSetEnumerable.java
/** Assigns a value to a dynamic parameter in a prepared statement, calling
 * the appropriate {@code setXxx} method based on the type of the value. */
private static void setDynamicParam(PreparedStatement preparedStatement,
    int i, Object value) throws SQLException {
  if (value == null) {
    preparedStatement.setObject(i, null, SqlType.ANY.id);
  } else if (value instanceof Timestamp) {
    preparedStatement.setTimestamp(i, (Timestamp) value);
  } else if (value instanceof Time) {
    preparedStatement.setTime(i, (Time) value);
  } else if (value instanceof String) {
    preparedStatement.setString(i, (String) value);
  } else if (value instanceof Integer) {
    preparedStatement.setInt(i, (Integer) value);
  } else if (value instanceof Double) {
    preparedStatement.setDouble(i, (Double) value);
  } else if (value instanceof java.sql.Array) {
    preparedStatement.setArray(i, (java.sql.Array) value);
  } else if (value instanceof BigDecimal) {
    preparedStatement.setBigDecimal(i, (BigDecimal) value);
  } else if (value instanceof Boolean) {
    preparedStatement.setBoolean(i, (Boolean) value);
  } else if (value instanceof Blob) {
    preparedStatement.setBlob(i, (Blob) value);
  } else if (value instanceof Byte) {
    preparedStatement.setByte(i, (Byte) value);
  } else if (value instanceof NClob) {
    preparedStatement.setNClob(i, (NClob) value);
  } else if (value instanceof Clob) {
    preparedStatement.setClob(i, (Clob) value);
  } else if (value instanceof byte[]) {
    preparedStatement.setBytes(i, (byte[]) value);
  } else if (value instanceof Date) {
    preparedStatement.setDate(i, (Date) value);
  } else if (value instanceof Float) {
    preparedStatement.setFloat(i, (Float) value);
  } else if (value instanceof Long) {
    preparedStatement.setLong(i, (Long) value);
  } else if (value instanceof Ref) {
    preparedStatement.setRef(i, (Ref) value);
  } else if (value instanceof RowId) {
    preparedStatement.setRowId(i, (RowId) value);
  } else if (value instanceof Short) {
    preparedStatement.setShort(i, (Short) value);
  } else if (value instanceof URL) {
    preparedStatement.setURL(i, (URL) value);
  } else if (value instanceof SQLXML) {
    preparedStatement.setSQLXML(i, (SQLXML) value);
  } else {
    preparedStatement.setObject(i, value);
  }
}
 
源代码12 项目: Zebra   文件: SQLXMLParamContext.java
@Override
public void setParam(PreparedStatement stmt) throws SQLException {
	stmt.setSQLXML(index, (SQLXML) values[0]);
}
 
源代码13 项目: StatsAgg   文件: DatabaseUtils.java
private static int setPreparedStatementParameter(PreparedStatement preparedStatement, List<Object> preparedStatementParameters, Object object, AtomicInteger index) {
    
    if ((preparedStatement == null) || (preparedStatementParameters == null)) {
        logger.warn("Can't set preparedStatementParameters - preparedStatementParameters or preparedStatement is null");
        return -1;
    } 

    try {
        if (object == null) {
            preparedStatement.setObject(index.getAndIncrement(), null);
        } 
        else if (object instanceof BigDecimal) {
            preparedStatement.setBigDecimal(index.getAndIncrement(), (BigDecimal) object);
        }
        else if (object instanceof Blob) {
            preparedStatement.setBlob(index.getAndIncrement(), (Blob) object);
        }
        else if (object instanceof Boolean) {
            preparedStatement.setBoolean(index.getAndIncrement(), (Boolean) object);
        }
        else if (object instanceof Byte) {
            preparedStatement.setByte(index.getAndIncrement(), (Byte) object);
        }
        else if (object instanceof byte[]) {
            preparedStatement.setBytes(index.getAndIncrement(), (byte[]) object);
        }
        else if (object instanceof Clob) {
            preparedStatement.setClob(index.getAndIncrement(), (Clob) object);
        }
        else if (object instanceof Double) {
            preparedStatement.setDouble(index.getAndIncrement(), (Double) object);
        }
        else if (object instanceof Float) {
            preparedStatement.setFloat(index.getAndIncrement(), (Float) object);
        }
        else if (object instanceof Integer) {
            preparedStatement.setInt(index.getAndIncrement(), (Integer) object);
        }
        else if (object instanceof List) {
            for (Object listObject : (List) object) {
                setPreparedStatementParameter(preparedStatement, preparedStatementParameters, listObject, index);
            }
        }
        else if (object instanceof Long) {
            preparedStatement.setLong(index.getAndIncrement(), (Long) object);
        }
        else if (object instanceof NClob) {
            preparedStatement.setNClob(index.getAndIncrement(), (NClob) object);
        }
        else if (object instanceof Ref) {
            preparedStatement.setRef(index.getAndIncrement(), (Ref) object);
        }
        else if (object instanceof RowId) {
            preparedStatement.setRowId(index.getAndIncrement(), (RowId) object);
        }
        else if (object instanceof SQLXML) {
            preparedStatement.setSQLXML(index.getAndIncrement(), (SQLXML) object);
        }
        else if (object instanceof Short) {
            preparedStatement.setShort(index.getAndIncrement(), (Short) object);
        }
        else if (object instanceof String) {
            preparedStatement.setString(index.getAndIncrement(), (String) object);
        }
        else if (object instanceof Time) {
            preparedStatement.setTime(index.getAndIncrement(), (Time) object);
        }
        else if (object instanceof java.sql.Timestamp) {
            preparedStatement.setTimestamp(index.getAndIncrement(), (java.sql.Timestamp) object);
        }
        else if (object instanceof java.sql.Date) {
            preparedStatement.setDate(index.getAndIncrement(), (java.sql.Date) object);
        }
        else if (object instanceof java.util.Date) {
            java.util.Date tempDate = (java.util.Date) object;
            java.sql.Date dateSql = new java.sql.Date(tempDate.getTime());
            preparedStatement.setDate(index.getAndIncrement(), dateSql);
        }
        else {
            if (object instanceof Object) {}
            else {
                logger.warn("Setting PreparedStatement parameter to 'object' type when object is not an object type");
            }
            
            preparedStatement.setObject(index.getAndIncrement(), object);
        }
        
        return index.get();
    }
    catch (Exception e) {
        logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));
        return -1;
    }  
    
}
 
源代码14 项目: calcite   文件: ResultSetEnumerable.java
/** Assigns a value to a dynamic parameter in a prepared statement, calling
 * the appropriate {@code setXxx} method based on the type of the value. */
private static void setDynamicParam(PreparedStatement preparedStatement,
    int i, Object value) throws SQLException {
  if (value == null) {
    preparedStatement.setObject(i, null, SqlType.ANY.id);
  } else if (value instanceof Timestamp) {
    preparedStatement.setTimestamp(i, (Timestamp) value);
  } else if (value instanceof Time) {
    preparedStatement.setTime(i, (Time) value);
  } else if (value instanceof String) {
    preparedStatement.setString(i, (String) value);
  } else if (value instanceof Integer) {
    preparedStatement.setInt(i, (Integer) value);
  } else if (value instanceof Double) {
    preparedStatement.setDouble(i, (Double) value);
  } else if (value instanceof java.sql.Array) {
    preparedStatement.setArray(i, (java.sql.Array) value);
  } else if (value instanceof BigDecimal) {
    preparedStatement.setBigDecimal(i, (BigDecimal) value);
  } else if (value instanceof Boolean) {
    preparedStatement.setBoolean(i, (Boolean) value);
  } else if (value instanceof Blob) {
    preparedStatement.setBlob(i, (Blob) value);
  } else if (value instanceof Byte) {
    preparedStatement.setByte(i, (Byte) value);
  } else if (value instanceof NClob) {
    preparedStatement.setNClob(i, (NClob) value);
  } else if (value instanceof Clob) {
    preparedStatement.setClob(i, (Clob) value);
  } else if (value instanceof byte[]) {
    preparedStatement.setBytes(i, (byte[]) value);
  } else if (value instanceof Date) {
    preparedStatement.setDate(i, (Date) value);
  } else if (value instanceof Float) {
    preparedStatement.setFloat(i, (Float) value);
  } else if (value instanceof Long) {
    preparedStatement.setLong(i, (Long) value);
  } else if (value instanceof Ref) {
    preparedStatement.setRef(i, (Ref) value);
  } else if (value instanceof RowId) {
    preparedStatement.setRowId(i, (RowId) value);
  } else if (value instanceof Short) {
    preparedStatement.setShort(i, (Short) value);
  } else if (value instanceof URL) {
    preparedStatement.setURL(i, (URL) value);
  } else if (value instanceof SQLXML) {
    preparedStatement.setSQLXML(i, (SQLXML) value);
  } else {
    preparedStatement.setObject(i, value);
  }
}