List of usage examples for java.sql ResultSet getInt
int getInt(String columnLabel) throws SQLException;
ResultSet
object as an int
in the Java programming language. From source file:tds.assessment.repositories.impl.StrandQueryRepositoryImpl.java
private static Strand buildStrandFromResultSet(final ResultSet rs) throws SQLException { return new Strand.Builder().withName(rs.getString("name")).withKey(rs.getString("_key")) .withMinItems(rs.getInt("minitems")).withMaxItems(rs.getInt("maxitems")) // calling getObject() and casting to Float because .getFloat() defaults to 0 if null .withAdaptiveCut((Float) rs.getObject("adaptivecut")).withSegmentKey(rs.getString("segmentKey")) .withStrictMax(rs.getBoolean("isstrictmax")).withBpWeight(rs.getFloat("bpweight")) .withStartInfo((Float) rs.getObject("startInfo")).withScalar((Float) rs.getObject("scalar")) .withPrecisionTarget((Float) rs.getObject("precisionTarget")) .withPrecisionTargetMetWeight((Float) rs.getObject("precisionTargetMetWeight")) .withPrecisionTargetNotMetWeight((Float) rs.getObject("precisionTargetNotMetWeight")).build(); }
From source file:com.l2jfree.gameserver.instancemanager.RaidPointsManager.java
public static void init() { _list.clear();//from w w w. j a v a2 s . c o m Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM character_raid_points"); ResultSet rset = statement.executeQuery(); while (rset.next()) getList(rset.getInt("charId")).put(rset.getInt("boss_id"), rset.getInt("points")); rset.close(); statement.close(); } catch (Exception e) { _log.warn("", e); } finally { L2DatabaseFactory.close(con); } }
From source file:com.data2semantics.yasgui.server.db.ConnectionFactory.java
private static ArrayList<Integer> getDeltas(Connection connect) throws SQLException { ArrayList<Integer> deltaIds = new ArrayList<Integer>(); String sql = "SELECT Id FROM Deltas WHERE 1 ORDER BY Id ASC"; Statement statement = connect.createStatement(); ResultSet result = statement.executeQuery(sql); while (result.next()) { deltaIds.add(result.getInt("Id")); }/*from w w w .j av a 2s. co m*/ return deltaIds; }
From source file:com.nabla.wapp.server.database.Database.java
/** * Get java <b>Integer</b> value from ResultSet (and not <b>int</b> value as it is the default!) * @param rs - query result/*from ww w . j ava2 s .co m*/ * @param column - name of column * @return null if it was NULL, value otherwise * @throws SQLException */ public static Integer getInteger(final ResultSet rs, final String column) throws SQLException { Assert.argumentNotNull(rs); int value = rs.getInt(column); return rs.wasNull() ? null : value; }
From source file:com.p6spy.engine.spy.P6TestUtil.java
public static int queryForInt(Connection con, String sql) throws SQLException { Statement stmt = null;/*from ww w . ja v a 2 s . c om*/ ResultSet rs = null; try { stmt = con.createStatement(); rs = stmt.executeQuery(sql); rs.next(); return rs.getInt(1); } finally { if (rs != null) try { rs.close(); } catch (Exception e) { } if (stmt != null) try { stmt.close(); } catch (Exception e) { } } }
From source file:com.nabla.wapp.server.database.Database.java
public static Integer addRecord(final Connection conn, final String sql, final Object... parameters) throws SQLException { final PreparedStatement stmt = StatementFormat.prepare(conn, Statement.RETURN_GENERATED_KEYS, sql, parameters);/*from w w w. j a va 2s . c o m*/ try { if (stmt.executeUpdate() != 1) { if (log.isErrorEnabled()) log.error("failed to add record"); return null; } final ResultSet rsKey = stmt.getGeneratedKeys(); try { rsKey.next(); return rsKey.getInt(1); } finally { rsKey.close(); } } finally { stmt.close(); } }
From source file:com.silverpeas.notation.model.RatingDAO.java
private static RatingRow resultSet2RatingRow(ResultSet rs) throws SQLException { return new RatingRow(rs.getInt(COLUMN_ID), rs.getString(COLUMN_INSTANCEID), rs.getString(COLUMN_CONTRIBUTION_ID), rs.getString(COLUMN_CONTRIBUTION_TYPE), rs.getString(COLUMN_RATER), rs.getInt(COLUMN_RATING)); }
From source file:TestDebug_MySQL.java
public static int countRows(Connection conn, String tableName) throws SQLException { Statement stmt = null;//ww w .ja v a 2s. com ResultSet rs = null; int rowCount = -1; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM " + tableName); // get the number of rows from the result set rs.next(); rowCount = rs.getInt(1); } finally { rs.close(); stmt.close(); } return rowCount; }
From source file:CountRows_MySQL.java
public static int countRows(Connection conn, String tableName) throws SQLException { // select the number of rows in the table Statement stmt = null;// w ww. jav a2 s.c om ResultSet rs = null; int rowCount = -1; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM " + tableName); // get the number of rows from the result set rs.next(); rowCount = rs.getInt(1); } finally { rs.close(); stmt.close(); } return rowCount; }
From source file:CountRows_Oracle.java
public static int countRows(Connection conn, String tableName) throws SQLException { // select the number of rows in the table Statement stmt = null;//from w w w. j a va 2 s. c om ResultSet rs = null; int rowCount = -1; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM " + tableName); // get the number of rows from the result set rs.next(); rowCount = rs.getInt(1); } finally { rs.close(); stmt.close(); } return rowCount; }