1.2 KiB
1.2 KiB
layout, title, header, resource, previoustitle, previous, nexttitle, next
layout | title | header | resource | previoustitle | previous | nexttitle | next |
---|---|---|---|---|---|---|---|
default_docs | Using the Statement or PreparedStatement Interface | Chapter 5. Issuing a Query and Processing the Result | media | Chapter 5. Issuing a Query and Processing the Result | query.html | Using the ResultSet Interface | resultset.html |
The following must be considered when using the Statement
or PreparedStatement
interface:
- You can use a single
Statement
instance as many times as you want. You could create one as soon as you open the connection and use it for the connection's lifetime. But you have to remember that only oneResultSet
can exist perStatement
orPreparedStatement
at a given time. - If you need to perform a query while processing a
ResultSet
, you can simply create and use anotherStatement
. - If you are using threads, and several are using the database, you must use a
separate
Statement
for each thread. Refer to Chapter 10, Using the Driver in a Multithreaded or a Servlet Environment if you are thinking of using threads, as it covers some important points. - When you are done using the
Statement
orPreparedStatement
you should close it.