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

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

源代码1 项目: mariadb-connector-j   文件: DataNTypeTest.java
@Test
public void testSetNClob() throws Exception {

  createTable("testSetNClob", "id int not null primary key, strm text", "CHARSET utf8");
  PreparedStatement stmt =
      sharedConnection.prepareStatement("insert into testSetNClob (id, strm) values (?,?)");
  NClob nclob = sharedConnection.createNClob();
  OutputStream stream = nclob.setAsciiStream(1);
  byte[] bytes = "hello".getBytes();
  stream.write(bytes);

  stmt.setInt(1, 1);
  stmt.setNClob(2, nclob);
  stmt.execute();

  ResultSet rs = sharedConnection.createStatement().executeQuery("select * from testSetNClob");
  assertTrue(rs.next());
  assertTrue(rs.getObject(2) instanceof String);
  assertTrue(rs.getString(2).equals("hello"));
  NClob resultNClob = rs.getNClob(2);
  assertNotNull(resultNClob);
  assertEquals(5, resultNClob.getAsciiStream().available());
}
 
源代码2 项目: Zebra   文件: NClobParamContext.java
@Override
public void setParam(PreparedStatement stmt) throws SQLException {
	if (values.length == 1 && values[0] instanceof NClob) {
		stmt.setNClob(index, (NClob) values[0]);
	} else if (values.length == 1 && values[0] instanceof Reader) {
		stmt.setNClob(index, (Reader) values[0]);
	} else if (values.length == 2) {
		stmt.setNClob(index, (Reader) values[0], (Long) values[1]);
	}

}
 
源代码3 项目: Oceanus   文件: PreparedStatementWrapper.java
@Override
public void setNClob(final int parameterIndex, final NClob value)
		throws SQLException {
	ParameterCallback callback = new ParameterCallbackAction(
			parameterIndex, value) {

		@Override
		public void call(PreparedStatement preparedStatement)
				throws SQLException {
			preparedStatement.setNClob(parameterIndex(), (NClob) value);
		}

	};
	addParameterCallback(callback);
}
 
源代码4 项目: Oceanus   文件: PreparedStatementWrapper.java
@Override
public void setNClob(final int parameterIndex, final Reader reader,
		final long length) throws SQLException {
	ParameterCallback callback = new ParameterCallbackAction(
			parameterIndex, reader) {
		@Override
		public void call(PreparedStatement preparedStatement)
				throws SQLException {
			preparedStatement.setNClob(parameterIndex(), reader, length);
		}

	};
	addParameterCallback(callback);

}
 
源代码5 项目: Oceanus   文件: PreparedStatementWrapper.java
@Override
public void setNClob(final int parameterIndex, final Reader reader)
		throws SQLException {
	ParameterCallback callback = new ParameterCallbackAction(
			parameterIndex, reader) {
		@Override
		public void call(PreparedStatement preparedStatement)
				throws SQLException {
			preparedStatement.setNClob(parameterIndex(), reader);
		}
	};
	addParameterCallback(callback);

}
 
@Override
public void set(PreparedStatement target, NClob value, int columnIndex, Context context) throws SQLException {
    if (value == null) {
        target.setNull(columnIndex, Types.NCLOB);
    } else {
        target.setNClob(columnIndex, value);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClob() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, (NClob) null);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClobForReader() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, new StringReader(""));
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClobForReaderAndLength() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, new StringReader(""), 1);
    }
}
 
源代码10 项目: 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);
  }
}
 
源代码11 项目: r-course   文件: StatementsTest.java
/**
 * Tests for ResultSet.updateNClob()
 * 
 * @throws Exception
 */
public void testUpdateNClob() throws Exception {
    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 NATIONAL CHARACTER(10)) default character set sjis");
    Properties props1 = new Properties();
    props1.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props1.put("characterEncoding", "UTF-8"); // ensure charset isn't utf8 here
    Connection conn1 = getConnectionWithProps(props1);
    PreparedStatement pstmt1 = conn1.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt1.setString(1, "1");
    NClob nClob1 = conn1.createNClob();
    nClob1.setString(1, "aaa");
    pstmt1.setNClob(2, nClob1);
    pstmt1.execute();
    Statement stmt1 = conn1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs1 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs1.next();
    NClob nClob2 = conn1.createNClob();
    nClob2.setString(1, "bbb");
    rs1.updateNClob("c2", nClob2);
    rs1.updateRow();
    rs1.moveToInsertRow();
    rs1.updateString("c1", "2");
    NClob nClob3 = conn1.createNClob();
    nClob3.setString(1, "ccc");
    rs1.updateNClob("c2", nClob3);
    rs1.insertRow();
    ResultSet rs2 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs2.next();
    assertEquals("1", rs2.getString("c1"));
    assertEquals("bbb", rs2.getNString("c2"));
    rs2.next();
    assertEquals("2", rs2.getString("c1"));
    assertEquals("ccc", rs2.getNString("c2"));
    pstmt1.close();
    stmt1.close();
    conn1.close();

    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 CHAR(10)) default character set sjis"); // sjis field
    Properties props2 = new Properties();
    props2.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props2.put("characterEncoding", "SJIS"); // ensure charset isn't utf8 here
    Connection conn2 = getConnectionWithProps(props2);
    PreparedStatement pstmt2 = conn2.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt2.setString(1, "1");
    pstmt2.setString(2, "aaa");
    pstmt2.execute();
    Statement stmt2 = conn2.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs3 = stmt2.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs3.next();
    NClob nClob4 = conn2.createNClob();
    nClob4.setString(1, "bbb");
    try {
        rs3.updateNClob("c2", nClob4); // field's charset isn't utf8
        fail();
    } catch (SQLException ex) {
        assertEquals("Can not call updateNClob() when field's character set isn't UTF-8", ex.getMessage());
    }
    rs3.close();
    pstmt2.close();
    stmt2.close();
    conn2.close();
}
 
源代码12 项目: Komondor   文件: StatementsTest.java
/**
 * Tests for ResultSet.updateNClob()
 * 
 * @throws Exception
 */
public void testUpdateNClob() throws Exception {
    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 NATIONAL CHARACTER(10)) default character set sjis");
    Properties props1 = new Properties();
    props1.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props1.put("characterEncoding", "UTF-8"); // ensure charset isn't utf8 here
    Connection conn1 = getConnectionWithProps(props1);
    PreparedStatement pstmt1 = conn1.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt1.setString(1, "1");
    NClob nClob1 = conn1.createNClob();
    nClob1.setString(1, "aaa");
    pstmt1.setNClob(2, nClob1);
    pstmt1.execute();
    Statement stmt1 = conn1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs1 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs1.next();
    NClob nClob2 = conn1.createNClob();
    nClob2.setString(1, "bbb");
    rs1.updateNClob("c2", nClob2);
    rs1.updateRow();
    rs1.moveToInsertRow();
    rs1.updateString("c1", "2");
    NClob nClob3 = conn1.createNClob();
    nClob3.setString(1, "ccc");
    rs1.updateNClob("c2", nClob3);
    rs1.insertRow();
    ResultSet rs2 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs2.next();
    assertEquals("1", rs2.getString("c1"));
    assertEquals("bbb", rs2.getNString("c2"));
    rs2.next();
    assertEquals("2", rs2.getString("c1"));
    assertEquals("ccc", rs2.getNString("c2"));
    pstmt1.close();
    stmt1.close();
    conn1.close();

    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 CHAR(10)) default character set sjis"); // sjis field
    Properties props2 = new Properties();
    props2.put("useServerPrepStmts", "true"); // use server-side prepared statement
    props2.put("characterEncoding", "SJIS"); // ensure charset isn't utf8 here
    Connection conn2 = getConnectionWithProps(props2);
    PreparedStatement pstmt2 = conn2.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt2.setString(1, "1");
    pstmt2.setString(2, "aaa");
    pstmt2.execute();
    Statement stmt2 = conn2.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs3 = stmt2.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs3.next();
    NClob nClob4 = conn2.createNClob();
    nClob4.setString(1, "bbb");
    try {
        rs3.updateNClob("c2", nClob4); // field's charset isn't utf8
        fail();
    } catch (SQLException ex) {
        assertEquals("Can not call updateNClob() when field's character set isn't UTF-8", ex.getMessage());
    }
    rs3.close();
    pstmt2.close();
    stmt2.close();
    conn2.close();
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClob() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, (NClob) null);
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClobForReader() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, new StringReader(""));
    }
}
 
@Test(expected = SQLFeatureNotSupportedException.class)
public void assertSetNClobForReaderAndLength() throws SQLException {
    for (PreparedStatement each : statements) {
        each.setNClob(1, new StringReader(""), 1);
    }
}
 
源代码16 项目: FoxTelem   文件: StatementsTest.java
/**
 * Tests for ResultSet.updateNClob()
 * 
 * @throws Exception
 */
public void testUpdateNClob() throws Exception {
    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 NATIONAL CHARACTER(10)) default character set sjis");
    Properties props1 = new Properties();
    props1.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "true"); // use server-side prepared statement
    props1.setProperty(PropertyKey.characterEncoding.getKeyName(), "UTF-8"); // ensure charset isn't utf8 here
    Connection conn1 = getConnectionWithProps(props1);
    PreparedStatement pstmt1 = conn1.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt1.setString(1, "1");
    NClob nClob1 = conn1.createNClob();
    nClob1.setString(1, "aaa");
    pstmt1.setNClob(2, nClob1);
    pstmt1.execute();
    Statement stmt1 = conn1.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs1 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs1.next();
    NClob nClob2 = conn1.createNClob();
    nClob2.setString(1, "bbb");
    rs1.updateNClob("c2", nClob2);
    rs1.updateRow();
    rs1.moveToInsertRow();
    rs1.updateString("c1", "2");
    NClob nClob3 = conn1.createNClob();
    nClob3.setString(1, "ccc");
    rs1.updateNClob("c2", nClob3);
    rs1.insertRow();
    ResultSet rs2 = stmt1.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs2.next();
    assertEquals("1", rs2.getString("c1"));
    assertEquals("bbb", rs2.getNString("c2"));
    rs2.next();
    assertEquals("2", rs2.getString("c1"));
    assertEquals("ccc", rs2.getNString("c2"));
    pstmt1.close();
    stmt1.close();
    conn1.close();

    createTable("testUpdateNChlob", "(c1 CHAR(10) PRIMARY KEY, c2 CHAR(10)) default character set sjis"); // sjis field
    Properties props2 = new Properties();
    props2.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "true"); // use server-side prepared statement
    props2.setProperty(PropertyKey.characterEncoding.getKeyName(), "SJIS"); // ensure charset isn't utf8 here
    Connection conn2 = getConnectionWithProps(props2);
    PreparedStatement pstmt2 = conn2.prepareStatement("INSERT INTO testUpdateNChlob (c1, c2) VALUES (?, ?)");
    pstmt2.setString(1, "1");
    pstmt2.setString(2, "aaa");
    pstmt2.execute();
    Statement stmt2 = conn2.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs3 = stmt2.executeQuery("SELECT c1, c2 FROM testUpdateNChlob");
    rs3.next();
    NClob nClob4 = conn2.createNClob();
    nClob4.setString(1, "bbb");
    try {
        rs3.updateNClob("c2", nClob4); // field's charset isn't utf8
        fail();
    } catch (SQLException ex) {
        assertEquals("Can not call updateNClob() when field's character set isn't UTF-8", ex.getMessage());
    }
    rs3.close();
    pstmt2.close();
    stmt2.close();
    conn2.close();
}
 
源代码17 项目: 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;
    }  
    
}
 
源代码18 项目: sockslib   文件: JdbcTemplate.java
private void setParameter(PreparedStatement preparedStatement, Object[] args) throws
    SQLException {
  if (args == null || args.length == 0) {
    return;
  }
  for (int i = 0; i < args.length; i++) {
    Object arg = args[i];
    if (TypeUtil.isInt(arg)) {
      preparedStatement.setInt(i + 1, (Integer) arg);
    } else if (TypeUtil.isString(arg)) {
      preparedStatement.setString(i + 1, (String) arg);
    } else if (TypeUtil.isLong(arg)) {
      preparedStatement.setLong(i + 1, (Long) arg);
    } else if (TypeUtil.isDouble(arg)) {
      preparedStatement.setDouble(i + 1, (Double) arg);
    } else if (TypeUtil.isFloat(arg)) {
      preparedStatement.setFloat(i + 1, (Float) arg);
    } else if (TypeUtil.isBoolean(arg)) {
      preparedStatement.setBoolean(i + 1, (Boolean) arg);
    } else if (TypeUtil.isByte(arg)) {
      preparedStatement.setByte(i + 1, (Byte) arg);
    } else if (TypeUtil.isDate(arg)) {
      preparedStatement.setDate(i + 1, (Date) arg);
    } else if (TypeUtil.isShort(arg)) {
      preparedStatement.setShort(i + 1, (Short) arg);
    } else if (TypeUtil.isArray(arg)) {
      preparedStatement.setArray(i + 1, (Array) arg);
    } else if (TypeUtil.isInputStream(arg)) {
      preparedStatement.setAsciiStream(i + 1, (InputStream) arg);
    } else if (TypeUtil.isBigDecimal(arg)) {
      preparedStatement.setBigDecimal(i + 1, (BigDecimal) arg);
    } else if (TypeUtil.isBlob(arg)) {
      preparedStatement.setBlob(i + 1, (Blob) arg);
    } else if (TypeUtil.isBytes(arg)) {
      preparedStatement.setBytes(i + 1, (byte[]) arg);
    } else if (TypeUtil.isClob(arg)) {
      preparedStatement.setClob(i + 1, (Clob) arg);
    } else if (TypeUtil.isNClob(arg)) {
      preparedStatement.setNClob(i + 1, (NClob) arg);
    } else {
      throw new IllegalArgumentException(
          "Type:" + arg.getClass().getName() + " is not supported");
    }
  }
}
 
源代码19 项目: 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);
  }
}