PostgreSQLConnection

com.github.mauricio.async.db.postgresql.PostgreSQLConnection
See thePostgreSQLConnection companion object
class PostgreSQLConnection(configuration: Configuration, encoderRegistry: ColumnEncoderRegistry, decoderRegistry: ColumnDecoderRegistry, group: EventLoopGroup, val executionContext: ExecutionContext) extends PostgreSQLConnectionDelegate, Connection, TimeoutScheduler

Attributes

Companion
object
Graph
Supertypes
trait TimeoutScheduler
trait Connection
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def clearNotifyListeners(): Unit
def connect: Future[Connection]

Connects this object to the database. Connection objects are not necessarily created with a connection to the database so you might have to call this method to be able to run queries against it.

Connects this object to the database. Connection objects are not necessarily created with a connection to the database so you might have to call this method to be able to run queries against it.

Attributes

override def disconnect: Future[Connection]

Disconnects this object. You should discard this object after calling this method. No more queries will be accepted.

Disconnects this object. You should discard this object after calling this method. No more queries will be accepted.

Attributes

Definition Classes
Connection
override def eventLoopGroup: EventLoopGroup

The event loop group to be used for scheduling.

The event loop group to be used for scheduling.

Attributes

Definition Classes
TimeoutScheduler
def hasRecentError: Boolean
override def isConnected: Boolean

Checks whether we are still connected to the database.

Checks whether we are still connected to the database.

Attributes

Definition Classes
Connection
def isReadyForQuery: Boolean
override def onAuthenticationResponse(message: AuthenticationMessage): Unit

Attributes

Definition Classes
override def onCommandComplete(m: CommandCompleteMessage): Unit

Attributes

Definition Classes
override def onDataRow(m: DataRowMessage): Unit

Attributes

Definition Classes
override def onError(exception: Throwable): Unit

Attributes

Definition Classes
override def onError(m: ErrorMessage): Unit

Attributes

Definition Classes
override def onNotificationResponse(message: NotificationResponse): Unit

Attributes

Definition Classes
override def onParameterStatus(m: ParameterStatusMessage): Unit

Attributes

Definition Classes
override def onReadyForQuery(): Unit

Attributes

Definition Classes
override def onRowDescription(m: RowDescriptionMessage): Unit

Attributes

Definition Classes
override def onTimeout: Unit

Implementors should decide here what they want to do when a timeout occur

Implementors should decide here what they want to do when a timeout occur

Attributes

Definition Classes
TimeoutScheduler
def parameterStatuses: Map[String, String]
def registerNotifyListener(listener: NotificationResponse => Unit): Unit
override def sendPreparedStatement(query: String, values: Seq[Any]): Future[QueryResult]

Sends a prepared statement to the database. Prepared statements are special statements that are pre-compiled by the database to run faster, they also allow you to avoid SQL injection attacks by not having to concatenate strings from possibly unsafe sources (like users) and sending them directy to the database.

Sends a prepared statement to the database. Prepared statements are special statements that are pre-compiled by the database to run faster, they also allow you to avoid SQL injection attacks by not having to concatenate strings from possibly unsafe sources (like users) and sending them directy to the database.

When sending a prepared statement, you can insert ? signs in your statement and then provide values at the method call 'values' parameter, as in:

 connection.sendPreparedStatement( "SELECT * FROM users WHERE users.login = ?", Array( "john-doe" ) )

As you are using the ? as the placeholder for the value, you don't have to perform any kind of manipulation to the value, just provide it as is and the database will clean it up. You must provide as many parameters as you have provided placeholders, so, if your query is as "INSERT INTO users (login,email) VALUES (?,?)" you have to provide an array with at least two values, as in:

 Array("john-doe", "[email protected]")

You can still use this method if your statement doesn't take any parameters, the default is an empty collection.

Attributes

Definition Classes
Connection
override def sendQuery(query: String): Future[QueryResult]

Sends a statement to the database. The statement can be anything your database can execute. Not all statements will return a collection of rows, so check the returned object if there are rows available.

Sends a statement to the database. The statement can be anything your database can execute. Not all statements will return a collection of rows, so check the returned object if there are rows available.

Attributes

Definition Classes
Connection
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def unregisterNotifyListener(listener: NotificationResponse => Unit): Unit
def validateIfItIsReadyForQuery(errorMessage: String): Unit

Inherited methods

def addTimeout[A](promise: Promise[A], durationOption: Option[Duration])(implicit executionContext: ExecutionContext): Option[ScheduledFuture[_]]

Attributes

Inherited from:
TimeoutScheduler
def inTransaction[A](f: Connection => Future[A])(implicit executionContext: ExecutionContext): Future[A]

Executes an (asynchronous) function within a transaction block. If the function completes successfully, the transaction is committed, otherwise it is aborted.

Executes an (asynchronous) function within a transaction block. If the function completes successfully, the transaction is committed, otherwise it is aborted.

Value parameters

f

operation to execute on this connection

Attributes

Returns

result of f, conditional on transaction operations succeeding

Inherited from:
Connection
def isTimeouted: Boolean

We need this property as isClosed takes time to complete and we don't want the connection to be used again.

We need this property as isClosed takes time to complete and we don't want the connection to be used again.

Attributes

Inherited from:
TimeoutScheduler
def schedule(block: => Unit, duration: Duration): ScheduledFuture[_]

Attributes

Inherited from:
TimeoutScheduler

Implicits

Implicits

implicit val executionContext: ExecutionContext