Class SqlBuilder
java.lang.Object
org.tamilnadujug.SqlBuilder
- Direct Known Subclasses:
SqlBuilder.PreparedSqlBuilder
public sealed class SqlBuilder
extends Object
implements Sql<Integer>
permits SqlBuilder.PreparedSqlBuilder
Utility class for building and executing SQL queries with dynamic
parameters. SqlBuilder helps manage SQL queries efficiently, reducing
boilerplate and supporting both query execution and parameterized
updates.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassinner Batch class of SqlBuilder.static final classstatic final class -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlBuilder(String theSql) Constructor that initializes the SqlBuilder with a given SQL query. -
Method Summary
Modifier and TypeMethodDescriptionadd Batch.execute(Connection connection) Executes the SQL operation using the given JDBC connection.protected booleanexists(Connection connection) Checks if Record Exists.protected StringgetSql()Get the SQL Query.prepareCall(String theSql) Builds Callable Sql Builder from Sql.prepareSql(String theSql) Builds Prerpared Sql Builder from Sql.Creates a new Query object that can be used to execute a SELECT query and map the result set to a BigDecimal.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Boolean.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte.Sql<byte[]> Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Date.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Double.Provides if record exists.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Float.Creates a new Query object that can be used to execute a SELECT query and map the result set to an Integer.queryForList(RowMapper<T> rowMapper) Creates a new Query object that can be used to execute a SELECT query and map the result set to list of a specific object type using the provided RowMapper.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of BigDecimal.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Boolean.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Byte.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Date.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Double.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Float.Creates a new Query object that can be used to execute a SELECT query and map the result set to List of Integer.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Long.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Object.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Short.Creates a new Query object that can be used to execute a SELECT query and map the result set to a String.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Time.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Timestamp.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of URL.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Long.Creates a new Query object that can be used to execute a SELECT query and map the result set to an Object.<T> Sql<T> queryForOne(RowMapper<T> rowMapper) Creates a new Query object that can be used to execute a SELECT query and map the result set to a specific object type using the provided RowMapper.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Short.Creates a new Query object that can be used to execute a SELECT query and map the result set to a String.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Time.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Timestamp.Creates a new Query object that can be used to execute a SELECT query and map the result set to a URL.Creates a new Query object that can be used to execute a SELECT query and map the result set to a BigDecimal.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Boolean.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte.Sql<byte[]> Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Date.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Double.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Float.Creates a new Query object that can be used to execute a SELECT query and map the result set to an Integer.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Long.Creates a new Query object that can be used to execute a SELECT query and map the result set to an Object.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Short.Creates a new Query object that can be used to execute a SELECT query and map the result set to a String.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Time.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Timestamp.Creates a new Query object that can be used to execute a SELECT query and map the result set to a URL.<T> Sql<T> queryGeneratedKeys(RowMapper<T> rowMapper) Creates a new Generated Keys object that can be used to execute a SELECT query and map the result set to a specific object type using the provided RowMapper.queryGeneratedKeysAsList(RowMapper<T> rowMapper) Creates query to get Generated Keys As a List.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of BigDecimal.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Boolean.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Byte.Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Date.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Double.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Float.Creates a new Query object that can be used to execute a SELECT query and map the result set to List of Integer.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Long.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Object.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of Short.Creates a new Query object that can be used to execute a SELECT query and map the result set to a String.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Time.Creates a new Query object that can be used to execute a SELECT query and map the result set List of Timestamp.Creates a new Query object that can be used to execute a SELECT query and map the result set the List of URL.static SqlBuilderBuilds Sql Builder from Sql.
-
Constructor Details
-
SqlBuilder
Constructor that initializes the SqlBuilder with a given SQL query.- Parameters:
theSql- the SQL query to be prepared and executed
-
-
Method Details
-
prepareCall
Builds Callable Sql Builder from Sql.- Parameters:
theSql- the SQL query to be prepared and executed- Returns:
- sqlBuilder
-
prepareSql
Builds Prerpared Sql Builder from Sql.- Parameters:
theSql- the SQL query to be prepared and executed- Returns:
- sqlBuilder
-
sql
Builds Sql Builder from Sql.- Parameters:
theSql- the SQL query to be prepared and executed- Returns:
- sqlBuilder
-
getSql
-
execute
Executes the SQL operation using the given JDBC connection.- Specified by:
executein interfaceSql<Integer>- Parameters:
connection- JDBC connection to use for execution- Returns:
- result of the SQL operation
- Throws:
SQLException- if an error occurs during execution
-
queryForExists
-
queryForByte
-
queryForListOfByte
-
queryForBytes
Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.- Returns:
- a new Query instance for execution
-
queryForListOfBytes
-
queryForInt
-
queryForListOfInt
-
queryForShort
-
queryForListOfShort
-
queryForString
-
queryForListOfString
-
queryForURL
-
queryForListOfURL
-
queryForDouble
-
queryForListOfDouble
-
queryForFloat
-
queryForListOfFloat
-
queryForBigDecimal
Creates a new Query object that can be used to execute a SELECT query and map the result set to a BigDecimal.- Returns:
- a new Query instance for execution
-
queryForListOfBigDecimal
Creates a new Query object that can be used to execute a SELECT query and map the result set the List of BigDecimal.- Returns:
- a new Query instance for execution
-
queryForBoolean
-
queryForListOfBoolean
-
queryForLong
-
queryForListOfLong
-
queryForDate
-
queryForListOfDate
-
queryForTime
-
queryForListOfTime
-
queryForTimestamp
-
queryForListOfTimestamp
-
queryForObject
-
queryForListOfObject
-
queryForOne
Creates a new Query object that can be used to execute a SELECT query and map the result set to a specific object type using the provided RowMapper.- Type Parameters:
T- the type of object to map the result set to- Parameters:
rowMapper- an implementation of RowMapper to map each row of the result set- Returns:
- a new Query instance for execution
-
queryForList
Creates a new Query object that can be used to execute a SELECT query and map the result set to list of a specific object type using the provided RowMapper.- Type Parameters:
T- the type of object to map the result set to- Parameters:
rowMapper- an implementation of RowMapper to map each row of the result set- Returns:
- a new Query instance for execution
-
exists
Checks if Record Exists.- Parameters:
connection-- Returns:
- exists
- Throws:
SQLException
-
addBatch
add Batch.- Parameters:
sqlQuery-- Returns:
- new Batch
-
queryGeneratedKeyForByte
-
queryGeneratedKeysAsListOfByte
-
queryGeneratedKeyForBytes
Creates a new Query object that can be used to execute a SELECT query and map the result set to a Byte Array.- Returns:
- a new Query instance for execution
-
queryGeneratedKeysAsListOfBytes
-
queryGeneratedKeyForInt
-
queryGeneratedKeysAsListOfInt
-
queryGeneratedKeyForShort
-
queryGeneratedKeysAsListOfShort
-
queryGeneratedKeyForString
-
queryGeneratedKeysAsListOfString
-
queryGeneratedKeyForURL
-
queryGeneratedKeysAsListOfURL
-
queryGeneratedKeyForDouble
-
queryGeneratedKeysAsListOfDouble
-
queryGeneratedKeyForFloat
-
queryGeneratedKeysAsListOfFloat
-
queryGeneratedKeyForBigDecimal
Creates a new Query object that can be used to execute a SELECT query and map the result set to a BigDecimal.- Returns:
- a new Query instance for execution
-
queryGeneratedKeysAsListOfBigDecimal
Creates a new Query object that can be used to execute a SELECT query and map the result set the List of BigDecimal.- Returns:
- a new Query instance for execution
-
queryGeneratedKeyForBoolean
-
queryGeneratedKeysAsListOfBoolean
-
queryGeneratedKeyForLong
-
queryGeneratedKeysAsListOfLong
-
queryGeneratedKeyForDate
-
queryGeneratedKeysAsListOfDate
-
queryGeneratedKeyForTime
-
queryGeneratedKeysAsListOfTime
-
queryGeneratedKeyForTimestamp
-
queryGeneratedKeysAsListOfTimestamp
-
queryGeneratedKeyForObject
-
queryGeneratedKeysAsListOfObject
-
queryGeneratedKeys
Creates a new Generated Keys object that can be used to execute a SELECT query and map the result set to a specific object type using the provided RowMapper.- Type Parameters:
T- the type of object to map the result set to- Parameters:
rowMapper- an implementation of RowMapper to map each row of the result set- Returns:
- a new Query instance for execution
-
queryGeneratedKeysAsList
Creates query to get Generated Keys As a List.- Type Parameters:
T- the type of object to map the result set to- Parameters:
rowMapper- an implementation of RowMapper to map each row of the result set- Returns:
- a new Query instance for execution
-