/** * Returns whether the cursors only support forward movement or are scroll * sensitive (with ResultSet.CONCUR_READ_ONLY concurrency). Returns always * false if not connected * * @return true if connected and the cursor is scroll-sensitive * @see ResultSet#TYPE_SCROLL_SENSITIVE * @see ResultSet#TYPE_FORWARD_ONLY * @see ResultSet#CONCUR_READ_ONLY */ public boolean isCursorScrollSensitive() { boolean result; result = false; try { if (isConnected()) { result = m_Connection.getMetaData().supportsResultSetConcurrency( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); } } catch (Exception e) { // ignored } return result; }
/** * Returns whether the cursors only support forward movement or are scroll * sensitive (with ResultSet.CONCUR_READ_ONLY concurrency). Returns always * false if not connected * * @return true if connected and the cursor is scroll-sensitive * @see ResultSet#TYPE_SCROLL_SENSITIVE * @see ResultSet#TYPE_FORWARD_ONLY * @see ResultSet#CONCUR_READ_ONLY */ public boolean isCursorScrollSensitive() { boolean result; result = false; try { if (isConnected()) { result = m_Connection.getMetaData().supportsResultSetConcurrency( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); } } catch (Exception e) { // ignored } return result; }
if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!");
if (!isConnected()) { throw new IllegalStateException("Not connected, please connect first!");
/** * 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 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 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; }
if (isConnected()) { if (m_Connection.getMetaData().supportsResultSetConcurrency( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
if (isConnected()) { if (m_Connection.getMetaData().supportsResultSetConcurrency( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY)) {