![]() |
Working with Connections and Transactions
|
|
Connecting to Multiple DatabasesAn application can connect to more than one database in a Cloudscape system. JBMSTours.ArchiveData is an example of such an application. It executes two methods that select data out of one database, inserts it into another (History), then deletes it from the first database (toursDB). These methods are the archiveRecords and the archiveRecordsVTI methods in the JBMSTours.serializabletypes.HotelStay class. The methods accomplish the same tasks in different ways. ArchiveData executes the methods as database-side JDBC methods (inside an SQL-J statement), but it could just as easily execute them on the application side. It executes them as database-side methods for illustration purposes only. The archiveRecords method creates two new connections: one to each database. That means that the work accomplished by the method is not encompassed by a single transaction and is not protected by transaction control. It must also handle the results programmatically; it steps through the ResultSet from the first database and inserts into the second database. The archiveRecordsVTI method, on the other hand, makes use of Cloudscape's VTI feature (which you learned about in External Virtual Tables) to transfer the data, and so does not need to handle the results programmatically. In addition, for some of the steps, it can re-use the current connection and so can allow some transaction control. Run JBMSTours.ArchiveData
|
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |