Java Reference
In-Depth Information
Method
Description
getMetaData()
Returns a MetaData object that can be used for obtaining table names
and column information.
getWarnings()
Returns a SQLWarning object containing supplemental information
about database interactions.
clearWarnings()
Clears the warnings so that future calls to getWarnings() returns null
until another warning occurs.
Unless you are writing a traditional client-server application, you might (seldom)
actually need to manage database connections. Enterprise Java and server-side
Java typically utilize a connection-pooling technology to manage database connec-
tions. A connection pool is a cluster of connections that can be reused as necessary
to fulfill the needs of applications. Since the cost of establishing connections and
maintaining large numbers of connections is significant, a pool reduces this over-
head. The Connection returned from the pool-management technology still be-
haves the same way as the Connection you would obtain directly from JDBC code.
Q UERYING A T ABLE
After connecting to the database, you will have created a Connection object that will
allow you to perform actions upon the database. One of the most common actions
is the query.
Java defines a Statement interface that you can use to process a variety of SQL
statements. You must first create an object of that type, based on your Connection
object.
Statement sqlStmt = dbConnection.createStatement();
The next step is to execute an SQL statement and place the results in a Result-
Set . A ResultSet object is one that will contain the rows that are returned for your
SQL statement. For example, this statement will select posting account IDs and
currency IDs from the posting_accounts table and place the results in the Result-
Set object named accounts :
 
Search WWH ::




Custom Search