[Java] Class SqlExtensions
- org.apache.groovy.sql.extensions.SqlExtensions
public class SqlExtensions
This class defines all the new SQL-related groovy methods which enhance the normal JDK SQL classes when inside the Groovy environment. Static methods are used with the first parameter the destination class.
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
public static boolean |
asBoolean(GroovyResultSet grs) Coerce a GroovyResultSet to a boolean value. | |
public static Iterator<ResultSetMetaDataWrapper> |
iterator(ResultSetMetaData resultSetMetaData) Return an Iterator given a ResultSetMetaData. | |
public static GroovyRowResult |
toRowResult(ResultSet rs) Returns a GroovyRowResult given a ResultSet. | |
public static Timestamp |
toTimestamp(Date d) Return a java.sql.Timestamp given a java.util.Date. |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail
public static boolean asBoolean(GroovyResultSet grs)
Coerce a GroovyResultSet to a boolean value. A GroovyResultSet is coerced to false if there are no more rows to iterate over, and to true otherwise.
- Parameters:
-
grs
- the GroovyResultSet
- Returns:
- the boolean value
- Since:
- 1.7.0
public static Iterator<ResultSetMetaDataWrapper> iterator(ResultSetMetaData resultSetMetaData)
Return an Iterator given a ResultSetMetaData. Enables Groovy collection method syntactic sugar on ResultSetMetaData.
- Parameters:
-
resultSetMetaData
- the ResultSetMetaData to iterate over
- Returns:
- an iterator for the ResultSetMetaData
- Since:
- 1.7
public static GroovyRowResult toRowResult(ResultSet rs)
Returns a GroovyRowResult given a ResultSet.
- throws:
- java.sql.SQLException if a database error occurs
- Parameters:
-
rs
- a ResultSet
- Returns:
- the resulting GroovyRowResult
- Since:
- 1.6.0
public static Timestamp toTimestamp(Date d)
Return a java.sql.Timestamp given a java.util.Date.
- Parameters:
-
d
- a date
- Returns:
- the date wrapped as a Timestamp
- Since:
- 1.6.6
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/apache/groovy/sql/extensions/SqlExtensions.html