/** * Checks whether cursors are scrollable in general, false otherwise (also if * not connected). * * @return true if scrollable and connected * @see #getSupportedCursorScrollType() */ public boolean isCursorScrollable() { return (getSupportedCursorScrollType() != -1); }
/** * Checks whether cursors are scrollable in general, false otherwise (also if * not connected). * * @return true if scrollable and connected * @see #getSupportedCursorScrollType() */ public boolean isCursorScrollable() { return (getSupportedCursorScrollType() != -1); }
/** * Executes a SQL DDL query or an INSERT, DELETE or UPDATE. * * @param query the SQL DDL query * @return the number of affected rows * @throws SQLException if an error occurs */ public int update(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } Statement statement; if (!isCursorScrollable()) { statement = m_Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { statement = m_Connection.createStatement(getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } int result = statement.executeUpdate(query); statement.close(); return result; }
/** * Executes a SQL DDL query or an INSERT, DELETE or UPDATE. * * @param query the SQL DDL query * @return the number of affected rows * @throws SQLException if an error occurs */ public int update(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } Statement statement; if (!isCursorScrollable()) { statement = m_Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { statement = m_Connection.createStatement(getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } int result = statement.executeUpdate(query); statement.close(); return result; }
/** * Executes a SQL query. Caller must clean up manually with * <code>close()</code>. * * @param query the SQL query * @return true if the query generated results * @throws SQLException if an error occurs * @see #close() */ public boolean execute(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } if (!isCursorScrollable()) { m_PreparedStatement = m_Connection.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { m_PreparedStatement = m_Connection.prepareStatement(query, getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } return (m_PreparedStatement.execute()); }
/** * Executes a SQL query. Caller must clean up manually with * <code>close()</code>. * * @param query the SQL query * @return true if the query generated results * @throws SQLException if an error occurs * @see #close() */ public boolean execute(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } if (!isCursorScrollable()) { m_PreparedStatement = m_Connection.prepareStatement(query, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { m_PreparedStatement = m_Connection.prepareStatement(query, getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } return (m_PreparedStatement.execute()); }
/** * Executes a SQL SELECT query that returns a ResultSet. Note: the ResultSet * object must be closed by the caller. * * @param query the SQL query * @return the generated ResultSet * @throws SQLException if an error occurs */ public ResultSet select(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } Statement statement; if (!isCursorScrollable()) { statement = m_Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { statement = m_Connection.createStatement(getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } ResultSet result = statement.executeQuery(query); return result; }
/** * Executes a SQL SELECT query that returns a ResultSet. Note: the ResultSet * object must be closed by the caller. * * @param query the SQL query * @return the generated ResultSet * @throws SQLException if an error occurs */ public ResultSet select(String query) throws SQLException { if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!"); } Statement statement; if (!isCursorScrollable()) { statement = m_Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } else { statement = m_Connection.createStatement(getSupportedCursorScrollType(), ResultSet.CONCUR_READ_ONLY); } ResultSet result = statement.executeQuery(query); return result; }