Java Code Examples for java.sql.PreparedStatement#setSQLXML()
The following examples show how to use
java.sql.PreparedStatement#setSQLXML() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreparedStatementAdapterTest.java From sharding-jdbc-1.5.1 with Apache License 2.0 | 5 votes |
@Test public void assertSetSQLXML() throws SQLException { for (PreparedStatement each : preparedStatements) { each.setSQLXML(1, null); assertParameter(each, 1, null); } }
Example 2
Source File: Jdbc4SqlXmlHandler.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example 3
Source File: Jdbc4SqlXmlHandler.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example 4
Source File: Jdbc4SqlXmlHandler.java From lams with GNU General Public License v2.0 | 5 votes |
@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); }
Example 5
Source File: Jdbc4SqlXmlHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: PreparedStatementAdapterTest.java From shardingsphere with Apache License 2.0 | 5 votes |
@Test public void assertSetSQLXML() throws SQLException { for (PreparedStatement each : preparedStatements) { each.setSQLXML(1, null); assertParameter(each, 1, null); } }
Example 7
Source File: ArgumentBinder.java From dalesbred with MIT License | 5 votes |
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); }
Example 8
Source File: PreparedStatementWrapper.java From Oceanus with Apache License 2.0 | 5 votes |
@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); }
Example 9
Source File: SQLXMLPreparedStatementIndexSetter.java From SimpleFlatMapper with MIT License | 5 votes |
@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); } }
Example 10
Source File: Jdbc4SqlXmlHandler.java From effectivejava with Apache License 2.0 | 5 votes |
@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); }
Example 11
Source File: ResultSetEnumerable.java From Quicksql with MIT License | 4 votes |
/** 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); } }
Example 12
Source File: SQLXMLParamContext.java From Zebra with Apache License 2.0 | 4 votes |
@Override public void setParam(PreparedStatement stmt) throws SQLException { stmt.setSQLXML(index, (SQLXML) values[0]); }
Example 13
Source File: DatabaseUtils.java From StatsAgg with Apache License 2.0 | 4 votes |
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; } }
Example 14
Source File: ResultSetEnumerable.java From calcite with Apache License 2.0 | 4 votes |
/** 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); } }