# Class: PreparedStatement

Defined in: | src/preparedstatement.coffee

## Direct Known Subclasses

CallableStatement

## Instance Method Summary

- # (void) setString(index, value) Binds a string value to the parameter with the `index`
- # (void) setInt(index, value) Binds a int value to the parameter with the `index`
- # (void) setTimestamp(index, value) Binds a Timestamp value to the parameter with the `index`
- # (int) executeUpdate() executes DDL(Data Definition Language) or DML(Data Manipulation Language) statements if DDL statement is executed returns nothing else returns the number of manipulated(inserted,updated,deleted) records
- # (int) executeUpdateSync() Same as {Statement.executeUpdate} except it runs synchronously and returns result directly
- # (void) addBatch() Adds a set of parameters to this PreparedStatement object's batch of commands.
- # (void) addBatchSync() Adds a set of parameters to this PreparedStatement object's batch of commands.
- # (?) executeBatch() Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.
- # (void) executeBatchSync() (see the jdbc doc)[https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#executeBatch()]
- # (ResultSet) executeQuery() Execute given SQL statement and return a promise to the result set @param SQL statement to be executed @example 'SELECT COLUMN_A from MY_TABLE'
- # (void) close() Closes the statement and frees the resources immediately.

## Constructor Details

# (void) constructor(preparedStatement)

constructor method

### Parameters:

- preparedStatement ( `Object` )

## Instance Method Details

# (void) setString(index, value)

Binds a string value to the parameter with the `index`

### Parameters:

- index ( `int` ) — order of the parameter to be binded indexes starts at 1
- value ( `string` ) — string value of the parameter

# (void) setInt(index, value)

Binds a int value to the parameter with the `index`

### Parameters:

- index ( `int` ) — order of the parameter to be binded indexes starts at 1
- value ( `int` ) — int value of the parameter

# (void) setTimestamp(index, value)

Binds a Timestamp value to the parameter with the `index`

### Parameters:

- index ( `int` ) — order of the paratemer to be binded indexes starts at 1
- string ( `string` ) — representation of JDBC timestamp

# (int) executeUpdate()

executes DDL(Data Definition Language) or DML(Data Manipulation Language) statements if DDL statement is executed returns nothing else returns the number of manipulated(inserted,updated,deleted) records

### Parameters:

- sql ( `String` ) — SQL statement to be executed @example 'SELECT COLUMN_A from MY_TABLE' @example 'DROP TABLE MY_TABLE'

### Returns:

- ( `int` ) — a promise that returns the result of the executed statement

# (int) executeUpdateSync()

Same as {Statement.executeUpdate} except it runs synchronously and returns result directly

### Returns:

- `int`

# (void) addBatch()

Adds a set of parameters to this PreparedStatement object's batch of commands.

# (void) addBatchSync()

Adds a set of parameters to this PreparedStatement object's batch of commands.

# (?) executeBatch()

Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. The int elements of the array that is returned are ordered to correspond to the commands in the batch, which are ordered according to the order in which they were added to the batch. The elements in the array returned by the method executeBatch may be one of the following: A number greater than or equal to zero -- indicates that the command was processed successfully and is an update count giving the number of rows in the database that were affected by the command's execution A value of SUCCESS_NO_INFO -- indicates that the command was processed successfully but that the number of rows affected is unknown If one of the commands in a batch update fails to execute properly, this method throws a BatchUpdateException, and a JDBC driver may or may not continue to process the remaining commands in the batch. However, the driver's behavior must be consistent with a particular DBMS, either always continuing to process commands or never continuing to process commands. If the driver continues processing after a failure, the array returned by the method BatchUpdateException.getUpdateCounts will contain as many elements as there are commands in the batch, and at least one of the elements will be the following:

A value of EXECUTE_FAILED -- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails The possible implementations and return values have been modified in the Java 2 SDK, Standard Edition, version 1.3 to accommodate the option of continuing to proccess commands in a batch update after a BatchUpdateException obejct has been thrown.

in the batch. The elements of the array are ordered according to the order in which commands were added to the batch.

### Returns:

- ( `?` ) — int[] an array of update counts containing one element for each command

# (void) executeBatchSync()

(see the jdbc doc)[https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#executeBatch()]

# (ResultSet) executeQuery()

Execute given SQL statement and return a promise to the result set

@param SQL statement to be executed @example 'SELECT COLUMN_A from MY_TABLE'

### Returns:

- ( `ResultSet` ) — a promise that returns ResultSet

# (void) close()

Closes the statement and frees the resources immediately.

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