Class ClientSidePreparedStatement

    • Constructor Detail

      • ClientSidePreparedStatement

        public ClientSidePreparedStatement​(MariaDbConnection connection,
                                           String sql,
                                           int resultSetScrollType,
                                           int resultSetConcurrency,
                                           int autoGeneratedKeys,
                                           ExceptionFactory exceptionFactory)
                                    throws SQLException
        Constructor.
        Parameters:
        connection - connection
        sql - sql query
        resultSetScrollType - one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
        resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
        autoGeneratedKeys - a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
        exceptionFactory - exception factory
        Throws:
        SQLException - exception
    • Method Detail

      • execute

        public boolean execute()
                        throws SQLException
        Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement. Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery and executeUpdate.
        The execute method returns a boolean to indicate the form of the first result. You must call either the method getResultSet or getUpdateCount to retrieve the result; you must call getInternalMoreResults to move to any subsequent result(s).
        Returns:
        true if the first result is a ResultSet object; false if the first result is an update count or there is no result
        Throws:
        SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or an argument is supplied to this method
        See Also:
        Statement.execute(java.lang.String), Statement.getResultSet(), Statement.getUpdateCount(), Statement.getMoreResults()
      • executeQuery

        public ResultSet executeQuery()
                               throws SQLException
        Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
        Returns:
        a ResultSet object that contains the data produced by the query; never null
        Throws:
        SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement does not return a ResultSet object
      • executeUpdate

        public int executeUpdate()
                          throws SQLException
        Executes the SQL statement in this PreparedStatement object, which must be an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement. Result-set are permitted for historical reason, even if spec indicate to throw exception.
        Returns:
        either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
        Throws:
        SQLException - if a database access error occurs; this method is called on a closed PreparedStatement
      • addBatch

        public void addBatch()
                      throws SQLException
        Adds a set of parameters to this PreparedStatement object's batch of send.

        Throws:
        SQLException - if a database access error occurs or this method is called on a closed PreparedStatement
        Since:
        1.2
        See Also:
        Statement.addBatch(java.lang.String)
      • getServerUpdateCounts

        public int[] getServerUpdateCounts()
        Non JDBC : Permit to retrieve server update counts when using option rewriteBatchedStatements.
        Returns:
        an array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.
      • executeLargeBatch

        public long[] executeLargeBatch()
                                 throws SQLException
        Execute batch, like executeBatch(), with returning results with long[]. For when row count may exceed Integer.MAX_VALUE.
        Specified by:
        executeLargeBatch in interface Statement
        Overrides:
        executeLargeBatch in class MariaDbStatement
        Returns:
        an array of update counts (one element for each command in the batch)
        Throws:
        SQLException - if a database error occur.
      • getMetaData

        public ResultSetMetaData getMetaData()
                                      throws SQLException
        Retrieves a ResultSetMetaData object that contains information about the columns of the ResultSet object that will be returned when this PreparedStatement object is executed.
        Because a PreparedStatement object is precompiled, it is possible to know about the ResultSet object that it will return without having to execute it. Consequently, it is possible to invoke the method getMetaData on a PreparedStatement object rather than waiting to execute it and then invoking the ResultSet.getMetaData method on the ResultSet object that is returned.
        Returns:
        the description of a ResultSet object's columns or null if the driver cannot return a ResultSetMetaData object
        Throws:
        SQLException - if a database access error occurs or this method is called on a closed PreparedStatement
      • clearParameters

        public void clearParameters()
        Clears the current parameter values immediately.

        In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method clearParameters.

      • close

        public void close()
                   throws SQLException
        Description copied from class: MariaDbStatement
        Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources. Calling the method close on a Statement object that is already closed has no effect. Note:When a Statement object is closed, its current ResultSet object, if one exists, is also closed.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Statement
        Overrides:
        close in class MariaDbStatement
        Throws:
        SQLException - if a database access error occurs
      • getParameterCount

        protected int getParameterCount()