Databases Reference
In-Depth Information
int numcols = WSrsmd.getColumnCount();
...
int ctype = WSrsmd.getColumnType(n)
...
// Result column information has now been obtained
// Note we also know the column ordering within the
// table!
What if the database system, such as Microsoft SQL Server, doesn't sup-
port prepared statements by default? The performance of Example A
wouldn't change, but the performance of Example B would decrease
slightly because the dummy query is evaluated in addition to being pre-
pared. Because the Where clause of the query always evaluates to
FALSE , the statement executes without retrieving result rows. So, even
with a slight decrease in performance, Example B still outperforms
Example A.
Summary
The performance of JDBC applications can suffer if they fail to reduce network
traffic, limit disk I/O, simplify queries, and optimize the interaction between the
application and driver. Reducing network communication probably is the most
important technique for improving performance. For example, when you need
to update large amounts of data, using batches rather than executing an Insert
statement multiple times reduces the number of network round trips required by
the driver to complete the operation.
Typically, creating a connection is the most performance-expensive task
your application performs. Connection pooling can help you manage connec-
tions efficiently, particularly if your application has numerous users. Regardless
of whether your application uses connection pooling, make sure that you close
connections immediately after your application is finished with them.
Making smart choices about how to handle transactions can also improve
performance. For example, using manual commits instead of auto-commit mode
provides better control over when work is committed. Similarly, if you don't need
the protection of distributed transactions, using local transactions can improve
performance.
 
Search WWH ::




Custom Search