Java Code Examples for java.sql.PreparedStatement#setURL()

The following examples show how to use java.sql.PreparedStatement#setURL() . 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 vote down vote up
@Test
public void assertSetURL() throws SQLException {
    for (PreparedStatement each : preparedStatements) {
        each.setURL(1, null);
        assertParameter(each, 1, null);
    }
}
 
Example 2
Source File: PreparedStatementAdapterTest.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
@Test
public void assertSetURL() throws SQLException {
    for (PreparedStatement each : preparedStatements) {
        each.setURL(1, null);
        assertParameter(each, 1, null);
    }
}
 
Example 3
Source File: PreparedStatementWrapper.java    From Oceanus with Apache License 2.0 5 votes vote down vote up
@Override
public void setURL(final int parameterIndex, final URL x)
		throws SQLException {
	ParameterCallback callback = new ParameterCallbackAction(
			parameterIndex, x) {

		@Override
		public void call(PreparedStatement preparedStatement)
				throws SQLException {
			preparedStatement.setURL(parameterIndex(), x);
		}

	};
	addParameterCallback(callback);
}
 
Example 4
Source File: URLPreparedStatementIndexSetter.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
@Override
public void set(PreparedStatement target, URL value, int columnIndex, Context context) throws SQLException {
    if (value == null) {
        target.setNull(columnIndex, Types.DATALINK);
    } else {
        target.setURL(columnIndex, value);
    }
}
 
Example 5
Source File: ResultSetEnumerable.java    From Quicksql with MIT License 4 votes vote down vote up
/** 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 6
Source File: UrlGetterMapping.java    From butterfly-persistence with Apache License 2.0 4 votes vote down vote up
protected void insertObjectDo(Object value, PreparedStatement statement, int index) throws SQLException {
    statement.setURL(index, (URL) value);
}
 
Example 7
Source File: URLParamContext.java    From Zebra with Apache License 2.0 4 votes vote down vote up
@Override
public void setParam(PreparedStatement stmt) throws SQLException {
	stmt.setURL(index, (URL) values[0]);
}
 
Example 8
Source File: ResultSetEnumerable.java    From calcite with Apache License 2.0 4 votes vote down vote up
/** 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);
  }
}