All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.gkutiel.store.Utils Maven / Gradle / Ivy

There is a newer version: 7-RELEASE
Show newest version
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);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy