Class TypedStatement


  • public class TypedStatement
    extends java.lang.Object
    A class that creates a PreparedStatement without having to type native sql code.
    Since:
    1.4.0
    • Constructor Detail

      • TypedStatement

        public TypedStatement​(QueryBuilder builder)
                       throws java.sql.SQLException
        Creates a query SELECT statement.
        Parameters:
        builder - the QueryBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • TypedStatement

        public TypedStatement​(UpdateBuilder builder)
                       throws java.sql.SQLException
        Creates an UPDATE statement.
        Parameters:
        builder - the UpdateBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • TypedStatement

        public TypedStatement​(DeleteBuilder builder)
                       throws java.sql.SQLException
        Creates an DELETE statement.
        Parameters:
        builder - the DeleteBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • TypedStatement

        public TypedStatement​(InsertBuilder builder)
                       throws java.sql.SQLException
        Creates an INSERT statement.
        Parameters:
        builder - the InsertBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • TypedStatement

        public TypedStatement​(TableBuilder builder)
                       throws java.sql.SQLException
        Creates a table CREATE statement.
        Parameters:
        builder - the TableBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
      • TypedStatement

        public TypedStatement​(IndexBuilder builder)
                       throws java.sql.SQLException
        Creates a index CREATE statement.
        Parameters:
        builder - the IndexBuilder that contains the statement
        Throws:
        java.sql.SQLException - if a database access error occurs
    • Method Detail

      • newQuery

        public static QueryBuilder newQuery()
        Creates a new instance of the QueryBuilder.
        Returns:
        a new instance of the QueryBuilder
      • newUpdate

        public static UpdateBuilder newUpdate()
        Creates a new instance of the UpdateBuilder.
        Returns:
        a new instance of the UpdateBuilder
      • newDelete

        public static DeleteBuilder newDelete()
        Creates a new instance of the DeleteBuilder.
        Returns:
        a new instance of the DeleteBuilder
      • newInsert

        public static InsertBuilder newInsert()
        Creates a new instance of the InsertBuilder.
        Returns:
        a new instance of the InsertBuilder
      • newTable

        public static TableBuilder newTable()
        Creates a new instance of the TableBuilder.
        Returns:
        a new instance of the TableBuilder
      • newIndex

        public static IndexBuilder newIndex()
        Creates a new instance of the IndexBuilder.
        Returns:
        a new instance of the IndexBuilder
      • executeQuery

        public java.sql.ResultSet executeQuery()
                                        throws java.sql.SQLException
        Executes the statement and returns the result-set.
        Returns:
        the result of the statement as a ResultSet
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.UnsupportedOperationException - if statement is not a query SELECT statement
      • executeInsert

        public int executeInsert()
                          throws java.sql.SQLException
        Executes the statement and returns the number of rows updated.
        Returns:
        the result of the statement as the number of rows updated
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.UnsupportedOperationException - if statement is not a INSERT statement
      • executeUpdate

        public int executeUpdate()
                          throws java.sql.SQLException
        Executes the statement and returns the number of rows updated.
        Returns:
        the result of the statement as a ResultSet
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.UnsupportedOperationException - if statement is not a UPDATE statement
      • executeLargeUpdate

        public long executeLargeUpdate()
                                throws java.sql.SQLException
        Executes the statement and returns the the number of rows updated. This method should be used when the returned row count may exceed Integer.MAX_VALUE.
        Returns:
        the result of the statement as a ResultSet
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.UnsupportedOperationException - if statement is not a UPDATE statement
      • executeCreate

        public boolean executeCreate()
                              throws java.sql.SQLException
        Executes the statement and returns true if no errors occurred.
        Returns:
        the result of the statement as a boolean, true if no errors occurred
        Throws:
        java.sql.SQLException - if a database access error occurs
        java.lang.UnsupportedOperationException - if statement is not a CREATE statement
      • getStatement

        public java.sql.PreparedStatement getStatement()
        Returns the PreparedStatement object that will generate ResultSet objects for sending SQL statements to the database.
        Returns:
        the PreparedStatement object
      • getType

        public TypedStatement.Type getType()
        Returns the statement type.
        Returns:
        the statement type
      • toString

        public java.lang.String toString()
        Returns the sql statement as a string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the sql statement as a string