AcolyteDSL

acolyte.jdbc.AcolyteDSL$
object AcolyteDSL

Acolyte DSL for JDBC.

import acolyte.jdbc.AcolyteDSL.{ connection, handleStatement }
// Useful: import acolyte.jdbc.Implicits._
import acolyte.jdbc.{ QueryExecution, UpdateExecution }

connection {
 handleStatement.withQueryDetection("...").
   withQueryHandler({ (_: QueryExecution) => ??? }).
   withUpdateHandler({ (_: UpdateExecution) => ??? })
}

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Concise view

Value members

Concrete methods

def connection(sh: AbstractCompositeHandler[_], p: (String, String)*): Connection

Creates a connection, whose statement will be passed to given handler.

Creates a connection, whose statement will be passed to given handler.

Attributes

p

the connection properties

sh

the statement handler

Returns:

a new Acolyte connection

import acolyte.jdbc.{ AcolyteDSL, ConnectionHandler }
import AcolyteDSL.connection
def foo(handler: ConnectionHandler) =
 connection(handler) // without connection properties
// With connection property to fallback untyped null
def bar(handler: ConnectionHandler) =
 connection(handler, "acolyte.parameter.untypedNull" -> "true")
def connection(sh: AbstractCompositeHandler[_], rh: ResourceHandler, p: (String, String)*): Connection

Creates a connection, whose statement will be passed to given handler.

Creates a connection, whose statement will be passed to given handler.

Attributes

p

the connection properties

rh

the resource handler

sh

the statement handler

Returns:

a new Acolyte connection

import acolyte.jdbc.{ AcolyteDSL, ConnectionHandler }
import AcolyteDSL.connection
def foo(handler: ConnectionHandler) =
 connection(handler) // without connection properties
// With connection property to fallback untyped null
def bar(handler: ConnectionHandler) =
 connection(handler, "acolyte.parameter.untypedNull" -> "true")
def connection(h: ConnectionHandler, p: (String, String)*): Connection

Creates a connection, managed with given handler.

Creates a connection, managed with given handler.

Attributes

h

connection handler

p

connection properties

Returns:

a new Acolyte connection

import acolyte.jdbc.{ AcolyteDSL, ConnectionHandler }
import AcolyteDSL.connection
def foo(handler: ConnectionHandler) =
 connection(handler) // without connection properties
// With connection property to fallback untyped null
def bar(handler: ConnectionHandler) =
 connection(handler, "acolyte.parameter.untypedNull" -> "true")
def debuging[A](printer: QueryExecution => Unit)(f: Connection => A): Unit

Manages a scope to debug any JDBC execution

Manages a scope to debug any JDBC execution

Attributes

f

the function working with the debug connection.

import acolyte.jdbc.AcolyteDSL
AcolyteDSL.debuging() { con =>
 val stmt = con.prepareStatement("SELECT * FROM Test WHERE id = ?")
 stmt.setString(1, "foo")
 stmt.executeQuery()
}
// print on stdout:
// => Executed query: QueryExecution(SELECT * FROM Test WHERE id = ?,List(Param(foo, VARCHAR)))
printer

the operation to print any QueryExecution that occurs within the scope of debuging.

Creates a new handler detecting all statements as queries (like handleStatement.withQueryDetection(".*").withQueryHandler(h)).

Creates a new handler detecting all statements as queries (like handleStatement.withQueryDetection(".*").withQueryHandler(h)).

import acolyte.jdbc.QueryResult
import acolyte.jdbc.AcolyteDSL.{ connection, handleQuery }

def foo(res: QueryResult) = connection(handleQuery { _ => res })

Attributes

Creates an empty handler.

Creates an empty handler.

import acolyte.jdbc.AcolyteDSL.{ connection, handleStatement }

connection { handleStatement }

Attributes

def handleTransaction(whenCommit: Connection => Unit, whenRollback: Connection => Unit): ResourceHandler

Returns a resource handler intercepting transaction commit or rollback.

Returns a resource handler intercepting transaction commit or rollback.

Attributes

whenCommit

the function handling commit

whenRollback

the function handling rollback

See also:

java.sql.Connection.commit

java.sql.Connection.rollback

def updateResult(count: Int, keys: RowList[_]): UpdateResult

Returns an update result with row count and generated keys.

Returns an update result with row count and generated keys.

Attributes

count

Updated (row) count

keys

Generated keys

import acolyte.jdbc.AcolyteDSL.updateResult
import acolyte.jdbc.RowLists
updateResult(2, RowLists.stringList("a", "b")) // 2 = updated rows
def withQueryResult[A](res: QueryResult)(f: Connection => A): A

Executes f using a connection accepting only queries, and answering with result to any query.

Executes f using a connection accepting only queries, and answering with result to any query.

import acolyte.jdbc.QueryResult
import acolyte.jdbc.AcolyteDSL.withQueryResult

def str(queryRes: QueryResult): String =
 withQueryResult(queryRes) { _ => "str" }

Attributes