public long getLong(int n) { try { ResultSet rs = getResultSet(); if (rs == null) return 0; return rs.getLong(n); } catch (Exception e) { Debug.warning(e); } return 0; }
public int getInteger(int n) { try { ResultSet rs = getResultSet(); if (rs == null) return 0; return rs.getInt(n); } catch (Exception e) { Debug.warning(e); } return 0; }
public long getDate(int n) { try { ResultSet rs = getResultSet(); if (rs == null) return 0; Date ts = rs.getDate(n); return ts.getTime(); } catch (Exception e) { Debug.warning(e); } return 0; }
public long getTimestamp(String name) { try { ResultSet rs = getResultSet(); if (rs == null) return 0; Timestamp ts = rs.getTimestamp(name); return ts.getTime(); } catch (Exception e) { Debug.warning(e); } return 0; }
public String getString(int n) { try { ResultSet rs = getResultSet(); if (rs == null) return ""; byte[] str_b = rs.getBytes(n); return new String(str_b); } catch (Exception e) { Debug.warning(e); } return ""; }
public boolean query(String sql) { try { Statement stmt = getStatement(); if (stmt != null) stmt.close(); ResultSet rs = getResultSet(); if (rs != null) rs.close(); Connection con = getConnection(); if (con == null) return false; stmt = con.createStatement(); setStatement(stmt); rs = stmt.executeQuery(sql); setResultSet(rs); } catch (Exception e) { Debug.warning(e); return false; } return true; }
public boolean fetch() { boolean fetchRet = false; try { ResultSet rs = getResultSet(); if (rs == null) return false; fetchRet = rs.next(); if (!fetchRet) { Statement stmt = getStatement(); if (stmt != null) { stmt.close(); setStatement(null); } rs.close(); setResultSet(null); } } catch (Exception e) { Debug.warning(e); } return fetchRet; }
public int update(String sql) { int numOfUpdated = 0; try { Statement stmt = getStatement(); if (stmt != null) { stmt.close(); setStatement(null); } ResultSet rs = getResultSet(); if (rs != null) { rs.close(); setResultSet(null); } Connection con = getConnection(); if (con == null) return 0; stmt = con.createStatement(); numOfUpdated = stmt.executeUpdate(sql); stmt.close(); } catch (Exception e) { Debug.warning(e); } return numOfUpdated; }