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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example: Disabling AutoCommit. The following example loads the driver andconnects to the database. Since new connections have auto-commit enabled bydefault, this example shows how to disable auto-commit. In the example, connrepresents the Connection object and stmt represents the Statementobject.// Load the <strong>Cincom</strong> ORDB <strong>JDBC</strong> driverDriverManager.registerDriver(new ordbjava.jdbc.ordbDriver());// Connect to the databaseConnection conn =DriverManager.getConnection ("jdbc:cincomordb:demodb", "public", null);// Let the application control transaction boundariesconn.setAutoCommit (false);// Create a StatementStatement stmt = conn.createStatement ();// Disable auto-commit mode for new connectionsordbjava.jdbc.ordbDriver.setAutoCommitDefault(false);Connection conn2 =DriverManager.getConnection ("jdbc:cincomordb:demodb", "public", null);System.out.println("auto-commit for conn2: " + conn2.getAutoCommit());Using the array interfaceUsing the getResultSet(..) methods of the Array interface can save memoryspace. The reason being that the ResultSet returned will only access a singlecollection element from the database when the ResultSet.next() method iscalled.When the getArray(..) methods are used, the driver must allocate a java arraylarge enough to contain all the elements requested, and then access theelements from the database.In any event, the workspace memory associated with the ordbCollection objectshould be freed by invoking the free() method after you are finished using theordbCollection.<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 88Chapter: 6. Coding tips and troubleshootingSection: Performance optimization

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

Saved successfully!

Ooh no, something went wrong!