Applying the solution proposed by Andrea I noticed that the method getConnection is protected, so it is not visible by my code. As a workaround I'm going to extend OracleDatastore (and factory) creating a new method with public visibility, but according to me it is not the final solution, because I am forced to extend OracleDatastore when I have to connect to an oracle database, or PostGisDatastore when I have to connect to a PostGis. It is useless to create a new class extending JDBCDatastore (OracleDatastore and PostgisDatastore does not extend the new class, so the new method will not be present...)
It it possible to modify the visibility of getConnection? Is it possible to have a JDBCDatastore constructor that use a connection previously created instead of a connection pool? -----Messaggio originale----- Da: Andrea Aime [mailto:[EMAIL PROTECTED] Inviato: martedì 17 aprile 2007 14.47 A: Alessandro Radaelli Cc: [email protected]; Federico Nieri Oggetto: Re: [Geotools-gt2-users] Geotools and database transactions Alessandro Radaelli ha scritto: > I think that geotools is a very powerful library and I want to > congratulate with all the developers. > > > > We are developing an application that have to > > 1 - insert a new feature in a geotools datastore (actually an > OracleDatastore). We are going to use geotools to accomplish this task > > 2 - insert some records in a lot of other db tables (in the same Oracle > schema). We are going to use jdbc to accomplish this task > > > > We need to issue both operations under the same transaction. How can we > do? Is there any example? No examples, but you can do the following: * create a new DefaultTransaction * call getConnection(transaction) from the JDBC data store you're using * use the connection to do whatever jdbc operations you need * use the same gt2 transaction in feature operations * commit the gt2 transaction * close the gt2 transaction Oh, don't close the connection you get at the second point, geotools will do it when you do close the gt2 transaction. Hope this helps Cheers Andrea ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
