Java Code Examples for java.sql.PreparedStatement#setBoolean()
The following examples show how to use
java.sql.PreparedStatement#setBoolean() .
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: EmbedDatabaseMetaData.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Does the actual work for the getIndexInfo metadata * calls. See getIndexInfo() method above for parameter * descriptions. * @param queryName Name of the query to execute; is used * to determine whether the result set should conform to * JDBC or ODBC specifications. */ private ResultSet doGetIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate, String queryName) throws SQLException { if (table == null) { throw Util.generateCsSQLException( SQLState.TABLE_NAME_CANNOT_BE_NULL); } int approximateInInt = 0; if (approximate) approximateInInt = 1; PreparedStatement s = getPreparedQuery(queryName); s.setString(1, swapNull(catalog)); s.setString(2, swapNull(schema)); s.setString(3, table); //DERBY-1484: Must match table name as stored s.setBoolean(4, unique); s.setInt(5, approximateInInt); return s.executeQuery(); }
Example 2
Source File: SiteUserFriendDao.java From wind-im with Apache License 2.0 | 6 votes |
public boolean updateUserFriendSetting(String siteUserId, UserFriendBean bean) throws SQLException { long startTime = System.currentTimeMillis(); String sql = "UPDATE " + USER_FRIEND_TABLE + " SET mute=? WHERE site_user_id=? AND site_friend_id=?;"; int result = 0; Connection conn = null; PreparedStatement ps = null; try { conn = DatabaseConnection.getConnection(); ps = conn.prepareStatement(sql); ps.setBoolean(1, bean.isMute()); ps.setString(2, siteUserId); ps.setString(3, bean.getSiteUserId()); result = ps.executeUpdate(); } catch (Exception e) { throw e; } finally { DatabaseConnection.returnConnection(conn, ps); } LogUtils.dbDebugLog(logger, startTime, result, sql, bean.isMute(), siteUserId, bean.getSiteUserId()); return result > 0; }
Example 3
Source File: MigrateUtils.java From openzaly with Apache License 2.0 | 6 votes |
private static void siteUserProfileRS(PreparedStatement ps, ResultSet rs) throws SQLException { ps.setInt(1, rs.getInt(1)); ps.setString(2, rs.getString(2)); ps.setString(3, rs.getString(3)); ps.setString(4, rs.getString(4)); ps.setString(5, rs.getString(5)); ps.setString(6, rs.getString(6)); ps.setString(7, rs.getString(7)); ps.setString(8, rs.getString(8)); ps.setString(9, rs.getString(9)); ps.setString(10, rs.getString(10)); ps.setString(11, rs.getString(11)); ps.setString(12, rs.getString(12)); ps.setString(13, rs.getString(13)); ps.setInt(14, rs.getInt(14)); ps.setBoolean(15, rs.getBoolean(15)); ps.setLong(16, rs.getLong(16)); ps.executeUpdate(); }
Example 4
Source File: EmbedDatabaseMetaData.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Does the actual work for the getIndexInfo metadata * calls. See getIndexInfo() method above for parameter * descriptions. * @param queryName Name of the query to execute; is used * to determine whether the result set should conform to * JDBC or ODBC specifications. */ private ResultSet doGetIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate, String queryName) throws SQLException { if (table == null) { throw Util.generateCsSQLException( SQLState.TABLE_NAME_CANNOT_BE_NULL); } int approximateInInt = 0; if (approximate) approximateInInt = 1; PreparedStatement s = getPreparedQuery(queryName); s.setString(1, swapNull(catalog)); s.setString(2, swapNull(schema)); s.setString(3, table); //DERBY-1484: Must match table name as stored s.setBoolean(4, unique); s.setInt(5, approximateInInt); return s.executeQuery(); }
Example 5
Source File: ConnectionIT.java From snowflake-jdbc with Apache License 2.0 | 6 votes |
@Test public void testPreparedStatementAsyncQuery() throws SQLException { Connection con = getConnection(); con.createStatement().execute("create or replace table testTable(colA string, colB boolean)"); PreparedStatement prepStatement = con.prepareStatement("insert into testTable values (?,?)"); prepStatement.setInt(1, 33); prepStatement.setBoolean(2, true); // call executeAsyncQuery ResultSet rs = prepStatement.unwrap(SnowflakePreparedStatement.class).executeAsyncQuery(); // Get access to results by calling next() function // next () will block until results are ready assertTrue(rs.next()); // the resultSet consists of a single row, single column containing the number of rows that have been updated by the insert // the number of updated rows in testTable is 1 so 1 is returned assertEquals(rs.getString(1), "1"); con.createStatement().execute("drop table testTable"); prepStatement.close(); con.close(); }
Example 6
Source File: LargeStoreQueries.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
/** * Execute a big batch of server infromation insert statements. * * @param servers Collection of Plan Servers. * @return Executable, use inside a {@link com.djrapitops.plan.storage.database.transactions.Transaction} */ public static Executable storeAllPlanServerInformation(Collection<Server> servers) { if (Verify.isEmpty(servers)) { return Executable.empty(); } return new ExecBatchStatement(ServerTable.INSERT_STATEMENT) { @Override public void prepare(PreparedStatement statement) throws SQLException { for (Server info : servers) { UUID uuid = info.getUuid(); String name = info.getName(); String webAddress = info.getWebAddress(); if (uuid == null) { continue; } statement.setString(1, uuid.toString()); statement.setString(2, name); statement.setString(3, webAddress); statement.setBoolean(4, true); statement.setInt(5, info.getMaxPlayers()); statement.addBatch(); } } }; }
Example 7
Source File: SQLQuery.java From micro-integrator with Apache License 2.0 | 5 votes |
private void setBitValue(int queryType, String value, String paramType, PreparedStatement sqlQuery, int i) throws SQLException { Boolean val = null; if (value != null) { val = Boolean.valueOf(value); } if (QueryTypes.IN.equals(paramType)) { if (queryType == SQLQuery.DS_QUERY_TYPE_NORMAL) { if (value == null) { sqlQuery.setNull(i + 1, Types.BIT); } else { sqlQuery.setBoolean(i + 1, val); } } else { if (value == null) { ((CallableStatement) sqlQuery).setNull(i + 1, Types.BIT); } else { ((CallableStatement) sqlQuery).setBoolean(i + 1, val); } } } else if (QueryTypes.INOUT.equals(paramType)) { if (value == null) { ((CallableStatement) sqlQuery).setNull(i + 1, Types.BIT); } else { ((CallableStatement) sqlQuery).setBoolean(i + 1, val); } ((CallableStatement) sqlQuery).registerOutParameter(i + 1, Types.BIT); } else { ((CallableStatement) sqlQuery).registerOutParameter(i + 1, Types.BIT); } }
Example 8
Source File: CertificateMgtDAO.java From carbon-apimgt with Apache License 2.0 | 5 votes |
/** * To check whether alias with the given value exist already. * * @param alias Relevant alias. * @return true if the alias exist, false if not. * @throws CertificateManagementException Certificate Management Exception. */ public boolean checkWhetherAliasExist(String alias, int tenantId) throws CertificateManagementException { Connection connection = null; PreparedStatement preparedStatement = null; String selectCertificateForAlias = SQLConstants.ClientCertificateConstants.SELECT_CERTIFICATE_FOR_ALIAS; boolean isExist = false; ResultSet resultSet = null; try { connection = APIMgtDBUtil.getConnection(); preparedStatement = connection.prepareStatement(selectCertificateForAlias); preparedStatement.setString(1, alias); preparedStatement.setBoolean(2, false); preparedStatement.setInt(3, tenantId); resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { isExist = true; if (log.isDebugEnabled()) { log.debug("Alias " + alias + " exist already and uploaded as a client certificate"); } } if (!isExist) { selectCertificateForAlias = SQLConstants.CertificateConstants.SELECT_CERTIFICATE_FOR_ALIAS; preparedStatement = connection.prepareStatement(selectCertificateForAlias); preparedStatement.setString(1, alias + "_" + tenantId); resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { isExist = true; if (log.isDebugEnabled()) { log.debug("Alias " + alias + " exist already and uploaded as a certificate for the backend"); } } } } catch (SQLException e) { handleException("Database error while checking whether alias " + alias + " exist in the database.", e); } finally { APIMgtDBUtil.closeAllConnections(preparedStatement, connection, resultSet); } return isExist; }
Example 9
Source File: SiteUserSessionDao.java From wind-im with Apache License 2.0 | 5 votes |
public boolean save(UserSessionBean bean) throws SQLException { long startTime = System.currentTimeMillis(); String sql = "INSERT INTO " + USER_SESSION_TABLE + "(site_user_id,session_id,is_online,device_id,login_time) VALUES(?,?,?,?,?);"; int result = 0; Connection conn = null; PreparedStatement ps = null; try { conn = DatabaseConnection.getConnection(); ps = conn.prepareStatement(sql); ps.setString(1, bean.getSiteUserId()); ps.setString(2, bean.getSessionId()); ps.setBoolean(3, bean.isOnline()); ps.setString(4, bean.getDeviceId()); ps.setLong(5, bean.getLoginTime()); result = ps.executeUpdate(); } catch (Exception e) { throw e; } finally { DatabaseConnection.returnConnection(conn, ps); } LogUtils.dbDebugLog(logger, startTime, result, sql, bean.getSiteUserId(), bean.getSessionId(), bean.isOnline(), bean.getDeviceId(), bean.getLoginTime()); return result > 0; }
Example 10
Source File: CursorTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Test cursor methods with parameter * * @throws SQLException */ public void testCursorParam() throws SQLException { PreparedStatement select; ResultSet cursor; // GemStone changes BEGIN //select = prepareStatement("select i, c from t where ?=1 for update"); select = prepareStatement("select i, c from t where ?=1 order by i desc"); // GemStone changes END select.setInt(1, 1); cursor = select.executeQuery(); // TEST: fetch of a row works assertTrue("FAIL: unable to fetch row.", cursor.next()); assertEquals("FAIL: Wrong row on fetch with param", 1956, cursor .getInt(1)); // TEST: Close and then fetch gets an error on fetch. cursor.close(); assertNextError("XCL16", cursor); // restart the query for another test select.setBoolean(1, false); select.setCursorName("ForCoverageSake"); cursor = select.executeQuery(); assertEquals("ForCoverageSake", cursor.getCursorName()); cursor.next(); if (usingEmbedded()) { assertGetIntError(1, "24000", cursor); } else if (usingDerbyNetClient()) { assertGetIntError(1, "XJ121", cursor); } cursor.close(); }
Example 11
Source File: AgentXmlToDBMigration.java From gocd with Apache License 2.0 | 5 votes |
private static void insert(Agent agent, Connection connection) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO agents (uuid, ipaddress, hostname, disabled, elasticAgentId, elasticPluginId, cookie, environments, resources, deleted) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); preparedStatement.setString(1, agent.uuid); preparedStatement.setString(2, agent.ipaddress); preparedStatement.setString(3, agent.hostname); preparedStatement.setBoolean(4, agent.isDisabled); preparedStatement.setString(5, agent.elasticAgentId); preparedStatement.setString(6, agent.elasticPluginId); preparedStatement.setString(7, UUID.randomUUID().toString()); preparedStatement.setString(8, agent.environments); preparedStatement.setString(9, agent.resources); preparedStatement.setBoolean(10, false); preparedStatement.execute(); }
Example 12
Source File: SiteUserSessionDao.java From openzaly with Apache License 2.0 | 5 votes |
public boolean save(UserSessionBean bean) throws SQLException { long startTime = System.currentTimeMillis(); String sql = "INSERT INTO " + USER_SESSION_TABLE + "(site_user_id,session_id,is_online,device_id,login_time) VALUES(?,?,?,?,?);"; int result = 0; Connection conn = null; PreparedStatement ps = null; try { conn = DatabaseConnection.getConnection(); ps = conn.prepareStatement(sql); ps.setString(1, bean.getSiteUserId()); ps.setString(2, bean.getSessionId()); ps.setBoolean(3, bean.isOnline()); ps.setString(4, bean.getDeviceId()); ps.setLong(5, bean.getLoginTime()); result = ps.executeUpdate(); } catch (Exception e) { throw e; } finally { DatabaseConnection.returnConnection(conn, ps); } LogUtils.dbDebugLog(logger, startTime, result, sql, bean.getSiteUserId(), bean.getSessionId(), bean.isOnline(), bean.getDeviceId(), bean.getLoginTime()); return result > 0; }
Example 13
Source File: RemoveUnsatisfiedConditionalPlayerResultsTransaction.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Executable deleteUnsatisfiedTableValues(String selectSatisfiedConditions) { String selectUnsatisfiedValueIDs = SELECT + ExtensionTableProviderTable.ID + FROM + tableTable + LEFT_JOIN + selectSatisfiedConditions + // Left join to preserve values that don't have their condition fulfilled " on (" + // Join when plugin_id matches and condition for the group provider is satisfied tableTable + '.' + ExtensionTableProviderTable.CONDITION + "=q1." + ExtensionProviderTable.PROVIDED_CONDITION + AND + tableTable + '.' + ExtensionTableProviderTable.PLUGIN_ID + "=q1." + ExtensionProviderTable.PLUGIN_ID + ')' + WHERE + "q1." + ExtensionProviderTable.PROVIDED_CONDITION + IS_NULL + // Conditions that were not in the satisfied condition query AND + ExtensionProviderTable.CONDITION + IS_NOT_NULL; // Ignore values that don't need condition // Nested query here is required because MySQL limits update statements with nested queries: // The nested query creates a temporary table that bypasses the same table query-update limit. // Note: MySQL versions 5.6.7+ might optimize this nested query away leading to an exception. String deleteValuesSQL = DELETE_FROM + playerTableValueTable + WHERE + ExtensionPlayerTableValueTable.TABLE_ID + " IN (" + SELECT + ExtensionTableProviderTable.ID + FROM + '(' + selectUnsatisfiedValueIDs + ") as ids)"; return new ExecStatement(deleteValuesSQL) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setBoolean(1, true); // Select provided conditions with 'true' value statement.setBoolean(2, false); // Select negated conditions with 'false' value } }; }
Example 14
Source File: QueryService.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
/** * @param preparedState * @param param * @throws SQLException */ private void setParam(PreparedStatement preparedState, int index, PrepareSqlRequest.StateParam param) throws SQLException { boolean isNull = (null == param.getValue()); Class<?> clazz; try { clazz = Class.forName(param.getClassName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } Rep rep = Rep.of(clazz); switch (rep) { case PRIMITIVE_CHAR: case CHARACTER: case STRING: preparedState.setString(index, isNull ? null : String.valueOf(param.getValue())); break; case PRIMITIVE_INT: case INTEGER: preparedState.setInt(index, isNull ? 0 : Integer.valueOf(param.getValue())); break; case PRIMITIVE_SHORT: case SHORT: preparedState.setShort(index, isNull ? 0 : Short.valueOf(param.getValue())); break; case PRIMITIVE_LONG: case LONG: preparedState.setLong(index, isNull ? 0 : Long.valueOf(param.getValue())); break; case PRIMITIVE_FLOAT: case FLOAT: preparedState.setFloat(index, isNull ? 0 : Float.valueOf(param.getValue())); break; case PRIMITIVE_DOUBLE: case DOUBLE: preparedState.setDouble(index, isNull ? 0 : Double.valueOf(param.getValue())); break; case PRIMITIVE_BOOLEAN: case BOOLEAN: preparedState.setBoolean(index, !isNull && Boolean.parseBoolean(param.getValue())); break; case PRIMITIVE_BYTE: case BYTE: preparedState.setByte(index, isNull ? 0 : Byte.valueOf(param.getValue())); break; case JAVA_UTIL_DATE: case JAVA_SQL_DATE: preparedState.setDate(index, isNull ? null : java.sql.Date.valueOf(param.getValue())); break; case JAVA_SQL_TIME: preparedState.setTime(index, isNull ? null : Time.valueOf(param.getValue())); break; case JAVA_SQL_TIMESTAMP: preparedState.setTimestamp(index, isNull ? null : Timestamp.valueOf(param.getValue())); break; default: preparedState.setObject(index, isNull ? null : param.getValue()); } }
Example 15
Source File: InjectWorkService.java From aws-doc-sdk-examples with Apache License 2.0 | 4 votes |
public String injestNewSubmission(WorkItem item) { Connection c = null; int rowCount= 0; try { // Create a Connection object c = ConnectionHelper.getConnection(); // Use a prepared statement PreparedStatement ps = null; // Convert rev to int String name = item.getName(); String guide = item.getGuide(); String description = item.getDescription(); String status = item.getStatus(); // generate the work item ID UUID uuid = UUID.randomUUID(); String workId = uuid.toString(); // Date conversion SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"); LocalDateTime now = LocalDateTime.now(); String sDate1 = dtf.format(now); Date date1 = new SimpleDateFormat("yyyy/MM/dd").parse(sDate1); java.sql.Date sqlDate = new java.sql.Date( date1.getTime()); // Inject an item into the system String insert = "INSERT INTO work (idwork, username,date,description, guide, status, archive) VALUES(?,?, ?,?,?,?,?);"; ps = c.prepareStatement(insert); ps.setString(1, workId); ps.setString(2, name); ps.setDate(3, sqlDate); ps.setString(4, description); ps.setString(5, guide ); ps.setString(6, status ); ps.setBoolean(7, false); ps.execute(); return workId; } catch (SQLException | ParseException e) { e.printStackTrace(); } finally { ConnectionHelper.close(c); } return null; }
Example 16
Source File: BooleanHandler.java From L2jOrg with GNU General Public License v3.0 | 4 votes |
@Override public void setParameter(PreparedStatement statement, int parameterIndex, Boolean arg) throws SQLException { statement.setBoolean(parameterIndex, arg); }
Example 17
Source File: BooleanDatabaseTypeSetter.java From multiapps-controller with Apache License 2.0 | 4 votes |
@Override public void setType(int columnIndex, PreparedStatement insertStatement, ResultSet sourceData) throws SQLException { insertStatement.setBoolean(columnIndex, sourceData.getBoolean(columnIndex)); }
Example 18
Source File: ExtensionPlayerDataQuery.java From Plan with GNU Lesser General Public License v3.0 | 4 votes |
private Query<Map<Integer, ExtensionData.Builder>> fetchIncompletePlayerDataByPluginID() { String sql = SELECT + "v1." + ExtensionPlayerValueTable.BOOLEAN_VALUE + " as boolean_value," + "v1." + ExtensionPlayerValueTable.DOUBLE_VALUE + " as double_value," + "v1." + ExtensionPlayerValueTable.PERCENTAGE_VALUE + " as percentage_value," + "v1." + ExtensionPlayerValueTable.LONG_VALUE + " as long_value," + "v1." + ExtensionPlayerValueTable.STRING_VALUE + " as string_value," + "p1." + ExtensionProviderTable.PLUGIN_ID + " as plugin_id," + "p1." + ExtensionProviderTable.PROVIDER_NAME + " as provider_name," + "p1." + ExtensionProviderTable.TEXT + " as text," + "p1." + ExtensionProviderTable.DESCRIPTION + " as description," + "p1." + ExtensionProviderTable.PRIORITY + " as provider_priority," + "p1." + ExtensionProviderTable.FORMAT_TYPE + " as format_type," + "p1." + ExtensionProviderTable.IS_PLAYER_NAME + " as is_player_name," + "t1." + ExtensionTabTable.TAB_NAME + " as tab_name," + "t1." + ExtensionTabTable.TAB_PRIORITY + " as tab_priority," + "t1." + ExtensionTabTable.ELEMENT_ORDER + " as element_order," + "i1." + ExtensionIconTable.ICON_NAME + " as provider_icon_name," + "i1." + ExtensionIconTable.FAMILY + " as provider_icon_family," + "i1." + ExtensionIconTable.COLOR + " as provider_icon_color," + "i2." + ExtensionIconTable.ICON_NAME + " as tab_icon_name," + "i2." + ExtensionIconTable.FAMILY + " as tab_icon_family," + "i2." + ExtensionIconTable.COLOR + " as tab_icon_color" + FROM + ExtensionPlayerValueTable.TABLE_NAME + " v1" + INNER_JOIN + ExtensionProviderTable.TABLE_NAME + " p1 on p1." + ExtensionProviderTable.ID + "=v1." + ExtensionPlayerValueTable.PROVIDER_ID + LEFT_JOIN + ExtensionTabTable.TABLE_NAME + " t1 on t1." + ExtensionTabTable.ID + "=p1." + ExtensionProviderTable.TAB_ID + LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i1 on i1." + ExtensionIconTable.ID + "=p1." + ExtensionProviderTable.ICON_ID + LEFT_JOIN + ExtensionIconTable.TABLE_NAME + " i2 on i2." + ExtensionIconTable.ID + "=p1." + ExtensionTabTable.ICON_ID + WHERE + ExtensionPlayerValueTable.USER_UUID + "=?" + AND + "p1." + ExtensionProviderTable.HIDDEN + "=?"; return new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) { @Override public void prepare(PreparedStatement statement) throws SQLException { statement.setString(1, playerUUID.toString()); statement.setBoolean(2, false); // Don't select hidden values } @Override public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException { return extractTabDataByPluginID(set).toExtensionDataByPluginID(); } }; }
Example 19
Source File: PlatformImplBase.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** * This is the core method to set the parameter of a prepared statement to a given value. * The primary purpose of this method is to call the appropriate method on the statement, * and to give database-specific implementations the ability to change this behavior. * * @param statement The statement * @param sqlIndex The parameter index * @param typeCode The JDBC type code * @param value The value * @throws SQLException If an error occurred while setting the parameter value */ protected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int typeCode, Object value) throws SQLException { if (value == null) { statement.setNull(sqlIndex, typeCode); } else if (value instanceof String) { statement.setString(sqlIndex, (String)value); } else if (value instanceof byte[]) { statement.setBytes(sqlIndex, (byte[])value); } else if (value instanceof Boolean) { statement.setBoolean(sqlIndex, ((Boolean)value).booleanValue()); } else if (value instanceof Byte) { statement.setByte(sqlIndex, ((Byte)value).byteValue()); } else if (value instanceof Short) { statement.setShort(sqlIndex, ((Short)value).shortValue()); } else if (value instanceof Integer) { statement.setInt(sqlIndex, ((Integer)value).intValue()); } else if (value instanceof Long) { statement.setLong(sqlIndex, ((Long)value).longValue()); } else if (value instanceof BigDecimal) { // setObject assumes a scale of 0, so we rather use the typed setter statement.setBigDecimal(sqlIndex, (BigDecimal)value); } else if (value instanceof Float) { statement.setFloat(sqlIndex, ((Float)value).floatValue()); } else if (value instanceof Double) { statement.setDouble(sqlIndex, ((Double)value).doubleValue()); } else { statement.setObject(sqlIndex, value, typeCode); } }
Example 20
Source File: QueryService.java From kylin with Apache License 2.0 | 4 votes |
/** * @param preparedState * @param param * @throws SQLException */ private void setParam(PreparedStatement preparedState, int index, PrepareSqlRequest.StateParam param) throws SQLException { boolean isNull = (null == param.getValue()); Class<?> clazz; try { clazz = Class.forName(param.getClassName()); } catch (ClassNotFoundException e) { throw new RuntimeException(e.getMessage(), e); } Rep rep = Rep.of(clazz); switch (rep) { case PRIMITIVE_CHAR: case CHARACTER: case STRING: preparedState.setString(index, isNull ? null : String.valueOf(param.getValue())); break; case PRIMITIVE_INT: case INTEGER: preparedState.setInt(index, isNull ? 0 : Integer.valueOf(param.getValue())); break; case PRIMITIVE_SHORT: case SHORT: preparedState.setShort(index, isNull ? 0 : Short.valueOf(param.getValue())); break; case PRIMITIVE_LONG: case LONG: preparedState.setLong(index, isNull ? 0 : Long.valueOf(param.getValue())); break; case PRIMITIVE_FLOAT: case FLOAT: preparedState.setFloat(index, isNull ? 0 : Float.valueOf(param.getValue())); break; case PRIMITIVE_DOUBLE: case DOUBLE: preparedState.setDouble(index, isNull ? 0 : Double.valueOf(param.getValue())); break; case PRIMITIVE_BOOLEAN: case BOOLEAN: preparedState.setBoolean(index, !isNull && Boolean.parseBoolean(param.getValue())); break; case PRIMITIVE_BYTE: case BYTE: preparedState.setByte(index, isNull ? 0 : Byte.valueOf(param.getValue())); break; case JAVA_UTIL_DATE: case JAVA_SQL_DATE: preparedState.setDate(index, isNull ? null : java.sql.Date.valueOf(param.getValue())); break; case JAVA_SQL_TIME: preparedState.setTime(index, isNull ? null : Time.valueOf(param.getValue())); break; case JAVA_SQL_TIMESTAMP: preparedState.setTimestamp(index, isNull ? null : Timestamp.valueOf(param.getValue())); break; default: preparedState.setObject(index, isNull ? null : param.getValue()); } }