Main Content

SQL Prepared Statements

Create and execute SQL prepared statements

An SQL prepared statement consists of a singleSELECT,INSERT,UPDATE,DELETE, orCALLSQL statement and has parameters that are bound to specified values.

Use theSQLPreparedStatementobject to create an SQL prepared statement. Then, you can import, insert, update, or delete data in the database. Also, you can call stored procedures. You import data using thefetchfunction. For other database operations, you use theexecutefunction.

An SQL prepared statement enables you to improve performance by executing one SQL statement with different values instead of creating multiple SQL statements. Also, an SQL prepared statement improves security by binding specified values to parameters.

You can use SQL prepared statements with a JDBC database connection only.

Objects

SQLPreparedStatement SQL prepared statement

Functions

expand all

databasePreparedStatement Create SQL prepared statement
bindParamValues Bind values to parameters
close Close SQL prepared statement
execute Execute SQL statement using relational database connection
fetch Import data intoMATLABworkspace from execution of SQL statement

Topics