Using JDBC
This section will be a brief introduction to JDBC, addressing the basics of JDBC, issues,
caveats, and so forth. For more detailed information, visit the JDBC website (http://java.sun.com/products/jdbc/), which has many good resources and
will always provide the most up to date information. Also, the API documentation included with
your JDK has detailed information on specific classes, methods, and fields. Look for the
java.sql
package.
JDBC has classes to represent most of the basic pieces of a programâs interaction with
SQL. The classes are: Connection
, Statement
, ResultSet
, Blob
, and Clob
, and they all map
directly to some concept in SQL. JDBC also has helper classes, such as ResultSetMetaData
and DatabaseMetaData
, that represent
meta-information. These are useful for when youâd like to get information about the
capabilities of the database. They are also useful for getting the types of results returned by
a query, either for debugging, or because you donât know about the data you are dealing
with.
PostgreSQLâs JDBC interface also provides classes to map to PostgreSQLâs non-standard
extensions to JDBCâs SQL support. These non-standard extensions include: Fastpath
, geometric types, native large objects, and a class that aids
serialization of Java objects into the database.
Basic JDBC Usage
Example 12-2 used a Connection
object, representing
a physical connection to the database. You can use this Connection
object
to create Statement
objects. Statement
objects ...
Get Practical PostgreSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.