10.07.2015 Views

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

JDBC Developer's Guide - Supra - Cincom

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

setConnectPoolTimeout(long milliseconds)The setConnectPoolTimeout(long milliseconds) static method of ordbDriver isused to enable, and disable pooling, or to alter the timeout duration forconnections. If zero is passed, all existing connections in the available poolwill be disconnected from the database, and connection pooling will bedisabled. If a non-zero value is specified, then connection pooling will beenabled. The parameter specifies the number of milliseconds that a databaseconnection should remain in the available connection pool before beingdisconnected from the database.long getConnectPoolTimeout()The getConnectPoolTimeout() will return zero if connection pooling is disabled(the default). The connection timeout value in milliseconds will be returned ifconnection pooling is enabled.By default, connection pooling is disabled.If you make use of connection pooling, you should make sure to issue anordbDriver.setConnectPoolTimeout(0) statement when your application exists.Failure to do this will result in spurious (but harmless) errors reported by thedatabase server occurring because of the open connections being terminatedwhen the client process (your application) shuts down.The file poolingSample.java in the %ORDB%\demo\jdbc\samples directorycontains an example that uses connection pooling.Trapping exceptions<strong>JDBC</strong> handles most errors that occur in the program as exceptions. Javaprovides the try...catch statement to catch the exception and theprintStackTrace() method to print the stack trace.The following code fragment illustrates how you can catch SQL exceptions andprint the stack trace:try { }catch(SQLException e){ e.printStackTrace (); }<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 90Chapter: 6. Coding tips and troubleshootingSection: Performance optimization

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!