# Class: Connection

Defined in: | src/connection.coffee

## Overview

Connection object to a datasource. @see {NodeJDBC#config} Queries and methods are executed using a connection object.

## Instance Method Summary

- # (void) setAutoCommit(autoCommit) Set the auto-commit mode of the connection
- # (Statement) createStatement() Create a statement for executing SQL queries.
- # (PreparedStatement) prepareStatement(sql) Creates a PreparedStatement for executing SQL statements with or without parameter binding.
- # (CallableStatement) prepareCall(call) Creates a CallableStatement object for calling database stored procedures.
- # (void) commit() Persists the changes to the datasource from the last commit.
- # (void) rollback() Ignore all the changes since last commit and release locks on the given datastore.
- # (void) close() Closes the connection to the given datasource.
- # (boolean) isClosed() Checks if the connection is closed
- # (void) isValid(timeout) Checks is connection is still valid

## Constructor Details

# (void) constructor(connection)

constructor method

### Parameters:

- connection ( `Object` ) — java connection insterface

## Instance Method Details

# (void) setAutoCommit(autoCommit)

Set the auto-commit mode of the connection

### Parameters:

- autoCommit ( `boolean` ) — true to set auto-commit mode on

# (Statement) createStatement()

Create a statement for executing SQL queries. SQL statements with no parameters can be executed by using Statement object. @example statement.executeQuery('SELECT COL_NAME FROM MY_TABLE')
If the sql statement is to be executed many times or with binding parameters Connection#prepareStatement should be used instead

### Returns:

- ( `Statement` ) — a promise that returns a statement Statement object that will create result set. @see ResultSet

# (PreparedStatement) prepareStatement(sql)

Creates a PreparedStatement for executing SQL statements with or without parameter binding. This is designed for precompilation optimization. If the driver supports precompilation option then given sql statement will be passed to datasource for precompilation once when this method is called. If precompilation is not supported then the SQL statement will be passed when the PreparedStatement object is executed.

### Returns:

- ( `PreparedStatement` ) — a promise that returs a PreparedStatement object

# (CallableStatement) prepareCall(call)

Creates a CallableStatement object for calling database stored procedures.

### Parameters:

- call ( `String` ) — stored procedure call expression @example "{call PROC_NAME(?, ?, ?)}"

### Returns:

- ( `CallableStatement` ) — a promise that returs a CallableStatement object

# (void) commit()

Persists the changes to the datasource from the last commit. This method throws exception if the auto-commit mode is on.

# (void) rollback()

Ignore all the changes since last commit and release locks on the given datastore. This method throws exception if the auto-commit mode is on.

# (void) close()

Closes the connection to the given datasource.

# (boolean) isClosed()

Checks if the connection is closed

### Returns:

- ( `boolean` ) — true if the connection is closed

# (void) isValid(timeout)

Checks is connection is still valid

### Parameters:

- timeout ( `int` ) — wait for number of (secods) to validate connection state

Quickly fuzzy find classes, mixins, methods, file:

- T Open fuzzy finder dialog

Control the navigation frame:

- L Toggle list view
- C Show class list
- I Show mixin list
- F Show file list
- M Show method list
- E Show extras list

You can focus and blur the search input:

- S Focus search input
- Esc Blur search input