Class FBPreparedStatement

    • Field Detail

      • METHOD_NOT_SUPPORTED

        public static final java.lang.String METHOD_NOT_SUPPORTED
        See Also:
        Constant Field Values
    • Constructor Detail

      • FBPreparedStatement

        protected FBPreparedStatement​(GDSHelper c,
                                      int rsType,
                                      int rsConcurrency,
                                      int rsHoldability,
                                      FBObjectListener.StatementListener statementListener,
                                      FBObjectListener.BlobListener blobListener)
                               throws java.sql.SQLException
        Create instance of this class for the specified result set type and concurrency. This constructor is used only in FBCallableStatement since the statement is prepared right before the execution.
        Parameters:
        c - instance of GDSHelper that will be used to perform all database activities.
        rsType - desired result set type.
        rsConcurrency - desired result set concurrency.
        statementListener - statement listener that will be notified about the statement start, close and completion.
        Throws:
        java.sql.SQLException - if something went wrong.
      • FBPreparedStatement

        protected FBPreparedStatement​(GDSHelper c,
                                      java.lang.String sql,
                                      int rsType,
                                      int rsConcurrency,
                                      int rsHoldability,
                                      FBObjectListener.StatementListener statementListener,
                                      FBObjectListener.BlobListener blobListener,
                                      boolean metaDataQuery,
                                      boolean standaloneStatement,
                                      boolean generatedKeys)
                               throws java.sql.SQLException
        Create instance of this class and prepare SQL statement.
        Parameters:
        c - connection to be used.
        sql - SQL statement to prepare.
        rsType - type of result set to create.
        rsConcurrency - result set concurrency.
        Throws:
        java.sql.SQLException - if something went wrong.
    • Method Detail

      • notifyStatementCompleted

        protected void notifyStatementCompleted​(boolean success)
                                         throws java.sql.SQLException
        Overrides:
        notifyStatementCompleted in class FBStatement
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery()
                                        throws java.sql.SQLException
        Specified by:
        executeQuery in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate()
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • getFirebirdParameterMetaData

        public FirebirdParameterMetaData getFirebirdParameterMetaData()
                                                               throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setNull

        public void setNull​(int parameterIndex,
                            int sqlType)
                     throws java.sql.SQLException
        Specified by:
        setNull in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBinaryStream

        public void setBinaryStream​(int parameterIndex,
                                    java.io.InputStream inputStream,
                                    int length)
                             throws java.sql.SQLException
        Specified by:
        setBinaryStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBinaryStream

        public void setBinaryStream​(int parameterIndex,
                                    java.io.InputStream inputStream,
                                    long length)
                             throws java.sql.SQLException
        Specified by:
        setBinaryStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBinaryStream

        public void setBinaryStream​(int parameterIndex,
                                    java.io.InputStream inputStream)
                             throws java.sql.SQLException
        Specified by:
        setBinaryStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBytes

        public void setBytes​(int parameterIndex,
                             byte[] x)
                      throws java.sql.SQLException
        Specified by:
        setBytes in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBoolean

        public void setBoolean​(int parameterIndex,
                               boolean x)
                        throws java.sql.SQLException
        Specified by:
        setBoolean in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setByte

        public void setByte​(int parameterIndex,
                            byte x)
                     throws java.sql.SQLException
        Specified by:
        setByte in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDate

        public void setDate​(int parameterIndex,
                            java.sql.Date x)
                     throws java.sql.SQLException
        Specified by:
        setDate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDouble

        public void setDouble​(int parameterIndex,
                              double x)
                       throws java.sql.SQLException
        Specified by:
        setDouble in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setFloat

        public void setFloat​(int parameterIndex,
                             float x)
                      throws java.sql.SQLException
        Specified by:
        setFloat in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setInt

        public void setInt​(int parameterIndex,
                           int x)
                    throws java.sql.SQLException
        Specified by:
        setInt in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setLong

        public void setLong​(int parameterIndex,
                            long x)
                     throws java.sql.SQLException
        Specified by:
        setLong in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int parameterIndex,
                              java.lang.Object x)
                       throws java.sql.SQLException
        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int parameterIndex,
                              java.lang.Object x,
                              java.sql.SQLType targetSqlType,
                              int scaleOrLength)
                       throws java.sql.SQLException

        Implementation note: behaves as setObject(int, Object, int, int) called with SQLType.getVendorTypeNumber().

        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int parameterIndex,
                              java.lang.Object x,
                              java.sql.SQLType targetSqlType)
                       throws java.sql.SQLException

        Implementation note: behaves as setObject(int, Object, int) called with SQLType.getVendorTypeNumber().

        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setShort

        public void setShort​(int parameterIndex,
                             short x)
                      throws java.sql.SQLException
        Specified by:
        setShort in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setString

        public void setString​(int parameterIndex,
                              java.lang.String x)
                       throws java.sql.SQLException
        Specified by:
        setString in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTime

        public void setTime​(int parameterIndex,
                            java.sql.Time x)
                     throws java.sql.SQLException
        Specified by:
        setTime in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTimestamp

        public void setTimestamp​(int parameterIndex,
                                 java.sql.Timestamp x)
                          throws java.sql.SQLException
        Specified by:
        setTimestamp in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBigDecimal

        public void setBigDecimal​(int parameterIndex,
                                  java.math.BigDecimal x)
                           throws java.sql.SQLException
        Specified by:
        setBigDecimal in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • getParameterDescriptor

        protected FieldDescriptor getParameterDescriptor​(int columnIndex)
        Returns the FieldDescriptor of the specified parameter.
        Parameters:
        columnIndex - 1-based index of the parameter
        Returns:
        Field descriptor
      • getField

        protected FBField getField​(int columnIndex)
                            throws java.sql.SQLException
        Factory method for the field access objects
        Throws:
        java.sql.SQLException
      • setAsciiStream

        public final void setAsciiStream​(int parameterIndex,
                                         java.io.InputStream x,
                                         int length)
                                  throws java.sql.SQLException

        Implementation note: works identical to setBinaryStream(int, InputStream, int).

        Specified by:
        setAsciiStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setAsciiStream

        public final void setAsciiStream​(int parameterIndex,
                                         java.io.InputStream x,
                                         long length)
                                  throws java.sql.SQLException

        Implementation note: works identical to setBinaryStream(int, InputStream, long).

        Specified by:
        setAsciiStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setAsciiStream

        public final void setAsciiStream​(int parameterIndex,
                                         java.io.InputStream x)
                                  throws java.sql.SQLException

        Implementation note: works identical to setBinaryStream(int, InputStream).

        Specified by:
        setAsciiStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setUnicodeStream

        @Deprecated
        public void setUnicodeStream​(int parameterIndex,
                                     java.io.InputStream x,
                                     int length)
                              throws java.sql.SQLException
        Deprecated.
        Method is no longer supported since Jaybird 3.0.

        For old behavior use setBinaryStream(int, InputStream, int). For JDBC suggested behavior, use setCharacterStream(int, Reader, int).

        Specified by:
        setUnicodeStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLFeatureNotSupportedException - Always
        java.sql.SQLException
      • setURL

        public void setURL​(int parameterIndex,
                           java.net.URL url)
                    throws java.sql.SQLException

        Jaybird does not support array types.

        Specified by:
        setURL in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNCharacterStream

        public void setNCharacterStream​(int parameterIndex,
                                        java.io.Reader value,
                                        long length)
                                 throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setCharacterStream(int, Reader, long).

        Specified by:
        setNCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNCharacterStream

        public void setNCharacterStream​(int parameterIndex,
                                        java.io.Reader value)
                                 throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setCharacterStream(int, Reader).

        Specified by:
        setNCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNClob

        public void setNClob​(int parameterIndex,
                             java.io.Reader reader,
                             long length)
                      throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setClob(int, Reader, long).

        Specified by:
        setNClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNClob

        public void setNClob​(int parameterIndex,
                             java.io.Reader reader)
                      throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setClob(int, Reader).

        Specified by:
        setNClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNString

        public void setNString​(int parameterIndex,
                               java.lang.String value)
                        throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setString(int, String).

        Specified by:
        setNString in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • clearParameters

        public void clearParameters()
                             throws java.sql.SQLException
        Specified by:
        clearParameters in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int parameterIndex,
                              java.lang.Object x,
                              int targetSqlType,
                              int scale)
                       throws java.sql.SQLException

        Implementation note: ignores scale and targetSqlType and works as setObject(int, Object).

        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setObject

        public void setObject​(int parameterIndex,
                              java.lang.Object x,
                              int targetSqlType)
                       throws java.sql.SQLException

        Implementation note: ignores targetSqlType and works as setObject(int, Object).

        Specified by:
        setObject in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute()
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • internalExecute

        protected boolean internalExecute​(boolean sendOutParams)
                                   throws java.sql.SQLException
        Execute this statement. Method checks whether all parameters are set, flushes all "flushable" fields that might contain cached data and executes the statement.
        Parameters:
        sendOutParams - Determines if the XSQLDA structure should be sent to the database
        Returns:
        true if the statement has more result sets.
        Throws:
        java.sql.SQLException
      • isGeneratedKeyQuery

        protected boolean isGeneratedKeyQuery()
        Overrides:
        isGeneratedKeyQuery in class FBStatement
        Returns:
        true when the current statement is expected to return generated keys, false otherwise.
      • addBatch

        public void addBatch()
                      throws java.sql.SQLException
        Specified by:
        addBatch in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • clearBatch

        public void clearBatch()
                        throws java.sql.SQLException
        Specified by:
        clearBatch in interface java.sql.Statement
        Overrides:
        clearBatch in class FBStatement
        Throws:
        java.sql.SQLException
      • executeBatchInternal

        protected java.util.List<java.lang.Long> executeBatchInternal()
                                                               throws java.sql.SQLException
        Overrides:
        executeBatchInternal in class FBStatement
        Throws:
        java.sql.SQLException
      • setCharacterStream

        public void setCharacterStream​(int parameterIndex,
                                       java.io.Reader reader,
                                       int length)
                                throws java.sql.SQLException
        Specified by:
        setCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setCharacterStream

        public void setCharacterStream​(int parameterIndex,
                                       java.io.Reader reader,
                                       long length)
                                throws java.sql.SQLException
        Specified by:
        setCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setCharacterStream

        public void setCharacterStream​(int parameterIndex,
                                       java.io.Reader reader)
                                throws java.sql.SQLException
        Specified by:
        setCharacterStream in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setRef

        public void setRef​(int i,
                           java.sql.Ref x)
                    throws java.sql.SQLException

        Jaybird does not support ref types.

        Specified by:
        setRef in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBlob

        public void setBlob​(int parameterIndex,
                            java.sql.Blob blob)
                     throws java.sql.SQLException
        Specified by:
        setBlob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBlob

        public void setBlob​(int parameterIndex,
                            java.io.InputStream inputStream,
                            long length)
                     throws java.sql.SQLException
        Specified by:
        setBlob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setBlob

        public void setBlob​(int parameterIndex,
                            java.io.InputStream inputStream)
                     throws java.sql.SQLException
        Specified by:
        setBlob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setClob

        public void setClob​(int parameterIndex,
                            java.sql.Clob clob)
                     throws java.sql.SQLException
        Specified by:
        setClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setClob

        public void setClob​(int parameterIndex,
                            java.io.Reader reader,
                            long length)
                     throws java.sql.SQLException
        Specified by:
        setClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setClob

        public void setClob​(int parameterIndex,
                            java.io.Reader reader)
                     throws java.sql.SQLException
        Specified by:
        setClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setArray

        public void setArray​(int i,
                             java.sql.Array x)
                      throws java.sql.SQLException

        Jaybird does not support array types.

        Specified by:
        setArray in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • getMetaData

        public java.sql.ResultSetMetaData getMetaData()
                                               throws java.sql.SQLException
        Specified by:
        getMetaData in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setDate

        public void setDate​(int parameterIndex,
                            java.sql.Date x,
                            java.util.Calendar cal)
                     throws java.sql.SQLException
        Specified by:
        setDate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTime

        public void setTime​(int parameterIndex,
                            java.sql.Time x,
                            java.util.Calendar cal)
                     throws java.sql.SQLException
        Specified by:
        setTime in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setTimestamp

        public void setTimestamp​(int parameterIndex,
                                 java.sql.Timestamp x,
                                 java.util.Calendar cal)
                          throws java.sql.SQLException
        Specified by:
        setTimestamp in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNull

        public void setNull​(int parameterIndex,
                            int sqlType,
                            java.lang.String typeName)
                     throws java.sql.SQLException
        Specified by:
        setNull in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • prepareFixedStatement

        protected void prepareFixedStatement​(java.lang.String sql)
                                      throws java.sql.SQLException
        Prepare fixed statement and initialize parameters.
        Overrides:
        prepareFixedStatement in class FBStatement
        Throws:
        java.sql.SQLException
      • getExecutionPlan

        public java.lang.String getExecutionPlan()
                                          throws java.sql.SQLException
        Description copied from interface: FirebirdPreparedStatement
        Get the execution plan of this PreparedStatement
        Specified by:
        getExecutionPlan in interface FirebirdPreparedStatement
        Returns:
        The execution plan of the statement
        Throws:
        java.sql.SQLException
      • getExplainedExecutionPlan

        public java.lang.String getExplainedExecutionPlan()
                                                   throws java.sql.SQLException
        Description copied from interface: FirebirdPreparedStatement
        Get the detailed execution plan of this PreparedStatement
        Specified by:
        getExplainedExecutionPlan in interface FirebirdPreparedStatement
        Returns:
        The detailed execution plan of the statement
        Throws:
        java.sql.SQLException
      • getStatementType

        public int getStatementType()
                             throws java.sql.SQLException
        Description copied from interface: FirebirdPreparedStatement
        Get the statement type of this PreparedStatement. The returned value will be one of the TYPE_* constant values.
        Specified by:
        getStatementType in interface FirebirdPreparedStatement
        Returns:
        The identifier for the given statement's type
        Throws:
        java.sql.SQLException
      • getParameterMetaData

        public java.sql.ParameterMetaData getParameterMetaData()
                                                        throws java.sql.SQLException
        Specified by:
        getParameterMetaData in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setNClob

        public void setNClob​(int parameterIndex,
                             java.sql.NClob value)
                      throws java.sql.SQLException

        Implementation note: This method behaves exactly the same as setClob(int, Clob).

        Specified by:
        setNClob in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setRowId

        public void setRowId​(int parameterIndex,
                             java.sql.RowId x)
                      throws java.sql.SQLException
        Specified by:
        setRowId in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • setSQLXML

        public void setSQLXML​(int parameterIndex,
                              java.sql.SQLXML xmlObject)
                       throws java.sql.SQLException

        Jaybird does not support SQLXML.

        Specified by:
        setSQLXML in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery​(java.lang.String sql)
                                        throws java.sql.SQLException
        Specified by:
        executeQuery in interface java.sql.Statement
        Overrides:
        executeQuery in class FBStatement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Overrides:
        executeUpdate in class FBStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Overrides:
        execute in class FBStatement
        Throws:
        java.sql.SQLException
      • addBatch

        public void addBatch​(java.lang.String sql)
                      throws java.sql.SQLException
        Specified by:
        addBatch in interface java.sql.Statement
        Overrides:
        addBatch in class FBStatement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 int autoGeneratedKeys)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Overrides:
        executeUpdate in class FBStatement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 int[] columnIndex)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Overrides:
        executeUpdate in class FBStatement
        Throws:
        java.sql.SQLException
      • executeUpdate

        public int executeUpdate​(java.lang.String sql,
                                 java.lang.String[] columnNames)
                          throws java.sql.SQLException
        Specified by:
        executeUpdate in interface java.sql.Statement
        Overrides:
        executeUpdate in class FBStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               int autoGeneratedKeys)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Overrides:
        execute in class FBStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               int[] columnIndexes)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Overrides:
        execute in class FBStatement
        Throws:
        java.sql.SQLException
      • execute

        public boolean execute​(java.lang.String sql,
                               java.lang.String[] columnNames)
                        throws java.sql.SQLException
        Specified by:
        execute in interface java.sql.Statement
        Overrides:
        execute in class FBStatement
        Throws:
        java.sql.SQLException
      • executeLargeUpdate

        public long executeLargeUpdate()
                                throws java.sql.SQLException
        Specified by:
        executeLargeUpdate in interface java.sql.PreparedStatement
        Throws:
        java.sql.SQLException