Three types of statements

In this chapter you will learn:

  1. Get to know the three types of JDBC statements

Statements in JDBC

We can issue sql statements to database through JDBC connection. There are three types of statements in JDBC we can use.

  • Statement
  • CallableStatement
  • PreparedStatement

They are both interfaces defining the methods and properties we can use to send sql commands to database and receive data from database.

The following table provides a summary of each interface.

InterfacesDescription
StatementUseful for static SQL statements. The Statement interface cannot accept parameters.
PreparedStatementUseful for passing parameters at runtime.
CallableStatementUseful for database stored procedures.

Next chapter...

What you will learn in the next chapter:

  1. Create and use Statement Object
  2. Execute SQL Statements
  3. Closing Statement Obeject
Home » Java Tutorial » Statements, ResultSet, Exception, Warning

Statement

    Three types of statements
    Statement interface
    Insert
    Delete records
    Drop a table
    Batch operation

PreparedStatement

    PreparedStatement
    Insert
    Delete
    Update with parameters
    Batch operation
    ParameterMetaData
    Fetch size
    Set null vaue

CallableStatement

    CallableStatement

ResultSet

    ResultSet
    ResultSet Type
    ResultSet Concurrency
    Create a ResultSet
    ResultSet reading
    ResultSet get by column name
    ResultSet get column by index
    ResultSet next row
    ResultSet table row count
    ResultSet navigation
    ResultSet cursor forward and backward
    ResultSet first
    ResultSet last
    ResultSet after last
    ResultSet before first
    ResultSet absolute(2)
    ResultSet absolute(-1)
    ResultSet relative(-2)
    ResultSet relative(-2)
    ResultSet update
    Column Names
    Column count
    Column Characteristics

ResultSetMetaData

    Column Names
    Column count
    Column Characteristics

SQL Exception, SQL Warning

    SQL Exception
    SQLException information
    Chaining SQLExceptions
    Connection Warning
    PreparedStatement SQLWarning
    Statement SQLWarning
    ResultSet warning
    SQLWarning information