little.sql
Type members
Classlikes
Creates database connections.
Creates database connections.
- Value Params
- driverClassName
fully qualified class name of JDBC driver
- password
database password
- url
database url
- user
database user
Represents result of either update or query. If update, result can be
obtained via count
; otherwise, if query, result can be obtained via
resultSet
.
Represents result of either update or query. If update, result can be
obtained via count
; otherwise, if query, result can be obtained via
resultSet
.
- See also
- Companion
- object
Provides factory methods for Execution.
Provides factory methods for Execution.
- Companion
- class
Provides implicits conversions and extension methods.
Provides implicits conversions and extension methods.
Provides factory methods for InParam.
Provides factory methods for InParam.
- Companion
- class
Provides interface to incrementally build and execute SQL statements.
Provides interface to incrementally build and execute SQL statements.
QueryBuilder
is an immutable structure. A new builder is returned with each
requested modification, and a new statement and result set are created on
each requested execution.
import java.sql.Connection
import scala.language.implicitConversions
import little.sql.Implicits.*
import little.sql.QueryBuilder
implicit val conn: Connection = ???
QueryBuilder("select * from users where group = ? and enabled = ?")
.params("staff", true) // Set input parameter values
.maxRows(10) // Limit result set to 10 rows
.foreach { rs => printf(s"uid=%d%n", rs.getInt("id")) } // Use implicit connection
// Same as above except use map of parameters
QueryBuilder("select * from users where group = ${group} and enabled = ${enabled}")
.params("group" -> "staff", "enabled" -> true)
.maxRows(10)
.foreach { rs => printf(s"uid=%d%n", rs.getInt("id")) }
- Companion
- object