com.github.gkutiel.store.Utils Maven / Gradle / Ivy
package com.github.gkutiel.store;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Utils {
static void set(final PreparedStatement ps, final int i, final Object val) {
try {
if (val instanceof Boolean) ps.setBoolean(i, (Boolean) val);
else if (val instanceof Integer) ps.setInt(i, (Integer) val);
else if (val instanceof Long) ps.setLong(i, (Long) val);
else if (val instanceof Double) ps.setDouble(i, (Double) val);
else if (val instanceof String) ps.setString(i, (String) val);
else throw new UnsupportedClassVersionError(val + " is not supported");
} catch (final SQLException e) {
throw new RuntimeException(e);
}
}
}