List of usage examples for java.sql ResultSet getStatement
Statement getStatement() throws SQLException;
Statement
object that produced this ResultSet
object. From source file:com.manydesigns.portofino.database.DbUtil.java
public static void closeResultSetAndStatement(ResultSet rs) { try {// ww w.ja va 2 s. c o m Statement st = rs.getStatement(); DbUtils.closeQuietly(st); } catch (Throwable e) { logger.debug("Could not close statement", e); } try { DbUtils.closeQuietly(rs); } catch (Throwable e) { logger.debug("Could not close result set", e); } }
From source file:com.l2jserver.model.template.NPCTemplateConverter.java
private static Skills fillSkillList(final ObjectFactory factory, ResultSet npcRs, int npcId) throws SQLException { final Connection conn = npcRs.getStatement().getConnection(); final Skills skills = factory.createNPCTemplateSkills(); final PreparedStatement st = conn.prepareStatement("SELECT * FROM npcskills WHERE npcid = ?"); st.setInt(1, npcId);//from w w w . jav a2 s. c o m st.execute(); final ResultSet rs = st.getResultSet(); while (rs.next()) { Skills.Skill s = factory.createNPCTemplateSkillsSkill(); s.setId(new SkillTemplateID(rs.getInt("skillid"), null)); s.setLevel(rs.getInt("level")); skills.getSkill().add(s); } if (skills.getSkill().size() == 0) return null; return skills; }
From source file:com.l2jserver.model.template.NPCTemplateConverter.java
private static Droplist fillDropList(final ObjectFactory factory, ResultSet npcRs, int npcId) throws SQLException { final Connection conn = npcRs.getStatement().getConnection(); final Droplist drops = factory.createNPCTemplateDroplist(); final PreparedStatement st = conn.prepareStatement("SELECT * FROM droplist WHERE mobId = ?"); st.setInt(1, npcId);//from ww w. j a va2 s . c o m st.execute(); final ResultSet rs = st.getResultSet(); while (rs.next()) { final Droplist.Item item = factory.createNPCTemplateDroplistItem(); item.setId(new ItemTemplateID(rs.getInt("itemId"), null)); item.setMin(rs.getInt("min")); item.setMax(rs.getInt("max")); item.setChance(rs.getInt("chance")); item.setCategory(getCategory(rs.getInt("category"))); drops.getItem().add(item); } if (drops.getItem().size() == 0) return null; return drops; }
From source file:gridool.util.jdbc.JDBCUtils.java
/** * Close a <code>ResultSet</code>, avoid closing if null. *///from w w w . jav a 2s . c om public static void closeAll(ResultSet rs) throws SQLException { if (rs != null) { Statement stmt = rs.getStatement(); if (stmt != null) { Connection conn = stmt.getConnection(); stmt.close(); closeQuietly(conn); } else { rs.close(); } } }
From source file:de.innovationgate.webgate.api.jdbc.custom.JDBCSource.java
public static void closeResultSet(ResultSet resultSet) { if (resultSet != null) { try {/* ww w. ja v a 2s.com*/ if (resultSet.getStatement() != null) { resultSet.getStatement().close(); } else { resultSet.close(); } } catch (SQLException e1) { Logger.getLogger(JDBCSource.LOGGER_NAME).error("Error closing result set in JDBC Source", e1); } } }
From source file:com.nabla.dc.server.xml.settings.XmlRole.java
public XmlRole(final ResultSet rs) throws SQLException { name = new XmlRoleName(rs.getString(2)); load(rs.getStatement().getConnection(), rs.getInt(1)); }
From source file:com.nabla.dc.server.xml.settings.XmlCompany.java
public XmlCompany(final ResultSet rs) throws SQLException { name = rs.getString(2);// w w w.j a va 2s . co m active = rs.getBoolean(3); load(rs.getStatement().getConnection(), rs.getInt(1)); }
From source file:com.nabla.dc.server.xml.settings.XmlUser.java
public XmlUser(final ResultSet rs) throws SQLException { name = new XmlUserName(rs.getString(2)); password = new XmlUserPassword("password"); // DO NOT reveal password here!!! active = rs.getBoolean(3);//from w w w.j a v a 2 s.c o m load(rs.getStatement().getConnection(), rs.getInt(1)); }
From source file:com.fer.hr.olap.util.ObjectUtil.java
public static List<SimpleCubeElement> convert2simple(ResultSet rs) { try {//from w w w .j a va 2s. co m int width = 0; boolean first = true; List<SimpleCubeElement> elements = new ArrayList<>(); if (rs != null) { while (rs.next()) { if (first) { first = false; width = rs.getMetaData().getColumnCount(); } String[] row = new String[3]; for (int i = 0; i < width; i++) { row[i] = rs.getString(i + 1); } SimpleCubeElement s = new SimpleCubeElement(row[0], row[1], row[2]); elements.add(s); } } return elements; } catch (Exception e) { throw new SaikuServiceException("Error converting ResultSet into SimpleCubeElement", e); } finally { if (rs != null) { Statement statement = null; Connection con = null; try { statement = rs.getStatement(); } catch (Exception e) { throw new SaikuServiceException(e); } finally { try { rs.close(); if (statement != null) { statement.close(); } } catch (Exception ee) { LOG.error("Could not close statement", ee); } rs = null; } } } }
From source file:hnu.helper.DataBaseConnection.java
/** * This method closes a Connection-object and a Statement-object from * a Resulset-object./* w w w . j a v a 2 s . co m*/ * IMPORTANT: Use this always after working on ResultSet returned by getRSfromStatement(). */ public boolean closeResultSet(ResultSet rs) { boolean returnValue = true; Statement stmt = null; Connection conn = null; if (rs != null) { try { stmt = rs.getStatement(); } catch (SQLException ex) { log.debug("Couldn't getStatement from rs."); returnValue = false; } } if (stmt != null) { try { conn = stmt.getConnection(); } catch (SQLException ex) { log.debug("Couldn't getConnection from stmt."); returnValue = false; } } if (stmt != null) { try { stmt.close(); } catch (SQLException ex) { log.debug("Couldn't close stmt."); returnValue = false; } } if (conn != null) { try { conn.close(); } catch (SQLException ex) { log.debug("Couldn't close conn."); returnValue = false; } } return returnValue; }