Package com.mckoi.database.jdbc
Class SQLQuery
java.lang.Object
com.mckoi.database.jdbc.SQLQuery
Represents an SQL Query to the database. This includes the query string
itself plus any data types that are part of the query.
FUTURE ENHANCEMENTS: This could do some preliminary parsing of the query string for faster translation by the database.
- Author:
- Tobias Downer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a variable to the query.void
clear()
Clears all the parameters.copy()
Creates an exact copy of this object.static SQLQuery
Deserializes an SQLQuery object from a ByteLongObject.boolean
Returns true if this query is equal to another.getQuery()
Returns the query string.Object[]
getVars()
Returns the array of all objects that are to be used as substitutions for '?' in the query.void
prepare
(boolean do_escape_processing) Prepares the query by parsing the query string and performing any updates that are required before being passed down to the lower layers of the database engine for processing.static SQLQuery
Reads an SQLQuery object from the data input stream.Serializes an SQLQuery object to a ByteLongObject.void
Sets a variable at the given index.toString()
Outputs the query as text (for debugging)void
writeTo
(DataOutputStream out) Writes the SQL query to the data output stream.
-
Constructor Details
-
SQLQuery
Constructs the query.
-
-
Method Details
-
addVar
Adds a variable to the query. If the object is not a type that is a database 'primitive' type (BigDecimal, ByteLongObject, Boolean, Date, String) then it is serialized and the serialized form is wrapped in a ByteLongObject. -
setVar
Sets a variable at the given index. Grows if necessary. If the object is not a type that is a database 'primitive' type (BigDecimal, ByteLongObject, Boolean, Date, String) then it is serialized and the serialized form is wrapped in a ByteLongObject. -
clear
public void clear()Clears all the parameters. -
getQuery
Returns the query string. -
getVars
Returns the array of all objects that are to be used as substitutions for '?' in the query.NOTE: Array returned references internal Object[] here so don't change!
-
prepare
Prepares the query by parsing the query string and performing any updates that are required before being passed down to the lower layers of the database engine for processing. For example, JDBC escape code processing.- Throws:
SQLException
-
equals
Returns true if this query is equal to another. -
copy
Creates an exact copy of this object. -
toString
Outputs the query as text (for debugging) -
writeTo
Writes the SQL query to the data output stream.- Throws:
IOException
-
readFrom
Reads an SQLQuery object from the data input stream.- Throws:
IOException
-
serializeToBlob
Serializes an SQLQuery object to a ByteLongObject. -
deserializeFromBlob
Deserializes an SQLQuery object from a ByteLongObject.
-