Class TypedStatement
- java.lang.Object
- 
- com.jgcomptech.tools.databasetools.jdbc.TypedStatement
 
- 
 public class TypedStatement extends java.lang.ObjectA class that creates a PreparedStatement without having to type native sql code.- Since:
- 1.4.0
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classTypedStatement.TypeA list of possible statement types.
 - 
Constructor SummaryConstructors Constructor Description TypedStatement(DeleteBuilder builder)Creates an DELETE statement.TypedStatement(IndexBuilder builder)Creates a index CREATE statement.TypedStatement(InsertBuilder builder)Creates an INSERT statement.TypedStatement(QueryBuilder builder)Creates a query SELECT statement.TypedStatement(TableBuilder builder)Creates a table CREATE statement.TypedStatement(UpdateBuilder builder)Creates an UPDATE statement.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexecuteCreate()Executes the statement and returns true if no errors occurred.intexecuteInsert()Executes the statement and returns the number of rows updated.longexecuteLargeUpdate()Executes the statement and returns the the number of rows updated.java.sql.ResultSetexecuteQuery()Executes the statement and returns the result-set.intexecuteUpdate()Executes the statement and returns the number of rows updated.java.sql.PreparedStatementgetStatement()Returns thePreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.TypedStatement.TypegetType()Returns the statement type.static DeleteBuildernewDelete()Creates a new instance of the DeleteBuilder.static IndexBuildernewIndex()Creates a new instance of the IndexBuilder.static InsertBuildernewInsert()Creates a new instance of the InsertBuilder.static QueryBuildernewQuery()Creates a new instance of the QueryBuilder.static TableBuildernewTable()Creates a new instance of the TableBuilder.static UpdateBuildernewUpdate()Creates a new instance of the UpdateBuilder.java.lang.StringtoString()Returns the sql statement as a string.
 
- 
- 
- 
Constructor Detail- 
TypedStatementpublic 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
 
 - 
TypedStatementpublic 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
 
 - 
TypedStatementpublic 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
 
 - 
TypedStatementpublic 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
 
 - 
TypedStatementpublic 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
 
 - 
TypedStatementpublic 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- 
newQuerypublic static QueryBuilder newQuery() Creates a new instance of the QueryBuilder.- Returns:
- a new instance of the QueryBuilder
 
 - 
newUpdatepublic static UpdateBuilder newUpdate() Creates a new instance of the UpdateBuilder.- Returns:
- a new instance of the UpdateBuilder
 
 - 
newDeletepublic static DeleteBuilder newDelete() Creates a new instance of the DeleteBuilder.- Returns:
- a new instance of the DeleteBuilder
 
 - 
newInsertpublic static InsertBuilder newInsert() Creates a new instance of the InsertBuilder.- Returns:
- a new instance of the InsertBuilder
 
 - 
newTablepublic static TableBuilder newTable() Creates a new instance of the TableBuilder.- Returns:
- a new instance of the TableBuilder
 
 - 
newIndexpublic static IndexBuilder newIndex() Creates a new instance of the IndexBuilder.- Returns:
- a new instance of the IndexBuilder
 
 - 
executeQuerypublic java.sql.ResultSet executeQuery() throws java.sql.SQLExceptionExecutes 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
 
 - 
executeInsertpublic int executeInsert() throws java.sql.SQLExceptionExecutes 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
 
 - 
executeUpdatepublic int executeUpdate() throws java.sql.SQLExceptionExecutes 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
 
 - 
executeLargeUpdatepublic long executeLargeUpdate() throws java.sql.SQLExceptionExecutes the statement and returns the the number of rows updated. This method should be used when the returned row count may exceedInteger.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
 
 - 
executeCreatepublic boolean executeCreate() throws java.sql.SQLExceptionExecutes 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
 
 - 
getStatementpublic java.sql.PreparedStatement getStatement() Returns thePreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.- Returns:
- the PreparedStatementobject
 
 - 
getTypepublic TypedStatement.Type getType() Returns the statement type.- Returns:
- the statement type
 
 - 
toStringpublic java.lang.String toString() Returns the sql statement as a string.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the sql statement as a string
 
 
- 
 
-