Updated on 2025-08-25 GMT+08:00

java.sql.PreparedStatement

java.sql.PreparedStatement is the statement preparation interface.

Table 1 Support for java.sql.PreparedStatement

Method

Return Type

JDBC 4 Support

clearParameters()

void

Yes

execute()

Boolean

Yes

executeQuery()

ResultSet

Yes

excuteUpdate()

int

Yes

getMetaData()

ResultSetMetaData

Yes

setBoolean(int parameterIndex, boolean x)

void

Yes

setBigDecimal(int parameterIndex, BigDecimal x)

void

Yes

setByte(int parameterIndex, byte x)

void

Yes

setBytes(int parameterIndex, byte[] x)

void

Yes

setDate(int parameterIndex, Date x)

void

Yes

setDouble(int parameterIndex, double x)

void

Yes

setFloat(int parameterIndex, float x)

void

Yes

setInt(int parameterIndex, int x)

void

Yes

setLong(int parameterIndex, long x)

void

Yes

setNString(int parameterIndex, String value)

void

Yes

setShort(int parameterIndex, short x)

void

Yes

setString(int parameterIndex, String x)

void

Yes

addBatch()

void

Yes

executeBatch()

int[]

Yes

clearBatch()

void

Yes

  • addBatch() and execute() can be executed only after clearBatch().
  • Calling the executeBatch() method does not clear the batch. Clear batch by explicitly calling clearBatch().
  • After adding a batch of bound variables, you can reuse these values (to add another batch) without needing to use the set*() method again.
  • The following methods are inherited from java.sql.Statement: close, execute, executeQuery, executeUpdate, getConnection, getResultSet, getUpdateCount, isClosed, setMaxRows, and setFetchSize.