Another option could be to use the new Oracle IO classes in Java
Topology Suite 1.8. This makes it really easy to convert JTS Geometry
into an Oracle STRUCT and should allow you to do transaction-based
inserts on many tables with more low level control of batch updates,
commits, etc...
http://www.vividsolutions.com/jts/jtshome.htm
After download, the Oracle IO (which is separate from regular JTS) is
under lib/jtsio-1.8.jar.
Example:
prepStmt.setTimestamp(1, new
Timestamp(toDate(feature.getAttribute("datetime").toString()+"
GMT","yyyyMMddHHmmss z").getTime()), cal);
prepStmt.setString(2,
feature.getAttribute("deciseconds").toString());
prepStmt.setString(3,
feature.getAttribute("datasource").toString());
prepStmt.setString(4,
feature.getAttribute("polarity").toString());
prepStmt.setString(5,
feature.getAttribute("stroke_type").toString());
prepStmt.setString(6,
feature.getAttribute("stroke_strength").toString());
prepStmt.setString(7,
feature.getAttribute("stroke_count").toString());
prepStmt.setObject(8,
oraWriter.write(feature.getDefaultGeometry()));
prepStmt.addBatch();
Steve
Jody Garnett said the following on 4/18/2007 3:34 PM:
Currently the oracle datastore is not maintained by anyone (so nobody
has answered your question).
Yes it would be possible to modify getConnection(), out of curiosity
what additonal jdbc operations do you need to perform? At least one
person who encountered this problem made a sql("") function which would
issue SQL on the internal connection.
Jody
Alessandro Radaelli wrote:
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
-------------------------------------------------------------------------
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
--
Steve Ansari
Physical Scientist
NOAA's National Climatic Data Center
Veach-Baley Federal Building
151 Patton Avenue
Asheville, NC 28801
Ph: 828-271-4611
Fax: 828-271-4022
-------------------------------------------------------------------------
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