This is a discussion on Data Migration within the pgsql Interfaces jdbc forums, part of the PostgreSQL category; --> Hi, Is there a way in JDBC to move data from one database to another without having to hard-wire ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, Is there a way in JDBC to move data from one database to another without having to hard-wire the table structure? I was wondering if I can do a kind of ResultSet rs = executeStatement("select * from table (from connection 1) where somecondition") while (rs.next()) take the resultset and then pass directly into a prepared statement for an "insert into table" (from connection 2) I can't see any way other disecting the values from the first query and using getSQLType. Any ideas? Thanks Rob |
| ||||
| Rob Kirkbride wrote: > Is there a way in JDBC to move data from one database to another without > having to hard-wire the table structure? > > I was wondering if I can do a kind of > > ResultSet rs = executeStatement("select * from table (from connection 1) > where somecondition") > while (rs.next()) > take the resultset and then pass directly into a prepared statement for > an "insert into table" (from connection 2) > > I can't see any way other disecting the values from the first query and > using getSQLType. That seems like the easiest solution to me. You can do it completely dynamically with no hard-wired table structure using the metadata. Perhaps you could do it with the JDBC 4 RowSet API? I haven't looked at it in detail. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |