Class SQLBuilder
- java.lang.Object
-
- com.jgcomptech.tools.databasetools.jdbc.builders.SQLBuilder
-
- Direct Known Subclasses:
DeleteBuilder,IndexBuilder,InsertBuilder,QueryBuilder,TableBuilder,UpdateBuilder
public abstract class SQLBuilder extends java.lang.ObjectAn abstract builder class for creating sql statements.- Since:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description SQLBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract TypedStatementbuild(Database db)Runs buildPreparedStatement and passes this object to a new instance ofTypedStatement.java.sql.PreparedStatementbuildPreparedStatement(Database db)Creates aPreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.protected java.lang.StringBuildergetSql()java.sql.PreparedStatementgetStatement()Returns thePreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.protected SQLBuildersetStatement(java.sql.PreparedStatement statement)java.lang.StringtoString()Returns the sql statement as a string.
-
-
-
Method Detail
-
buildPreparedStatement
public final java.sql.PreparedStatement buildPreparedStatement(Database db) throws java.sql.SQLException
Creates aPreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.- Parameters:
db- the database to request thePreparedStatementobject from- Returns:
- a new
PreparedStatementobject containing the pre-compiled SQL statement - Throws:
java.sql.SQLException- if a database access error occurs
-
build
public abstract TypedStatement build(Database db) throws java.sql.SQLException
Runs buildPreparedStatement and passes this object to a new instance ofTypedStatement.- Parameters:
db- the database to request thePreparedStatementobject from- Returns:
- a new instance of
TypedStatement - Throws:
java.sql.SQLException- if a database access error occurs
-
getStatement
@Contract(pure=true) public final java.sql.PreparedStatement getStatement()
Returns thePreparedStatementobject that will generateResultSetobjects for sending SQL statements to the database.- Returns:
- the
PreparedStatementobject, null if buildPreparedStatement has not been run
-
setStatement
protected SQLBuilder setStatement(java.sql.PreparedStatement statement)
-
getSql
protected java.lang.StringBuilder getSql()
-
toString
public java.lang.String toString()
Returns the sql statement as a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- the sql statement as a string
-
-