X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2F116D1B449 for ; Mon, 22 Dec 2003 19:33:30 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 70970-03 for ; Mon, 22 Dec 2003 15:32:42 -0400 (AST) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 094C6D1B440 for ; Mon, 22 Dec 2003 15:32:40 -0400 (AST) Received: (qmail 23022 invoked from network); 22 Dec 2003 19:32:20 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 22 Dec 2003 19:32:20 -0000 Subject: Re: Insert Row to ResultSet From: Dave Cramer Reply-To: pg@fastcrypt.com To: "Jason L. van Brackel" Cc: "pgsql-jdbc@postgresql.org" In-Reply-To: <621ddc9b.0312160724.6c6955db@posting.google.com> References: <621ddc9b.0312160724.6c6955db@posting.google.com> Content-Type: text/plain Organization: Cramer Consulting Message-Id: <1072121539.1634.84.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 22 Dec 2003 14:32:19 -0500 Content-Transfer-Encoding: 7bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/150 X-Sequence-Number: 8886 Jason, A couple of things, 1) can you send us the table definitions, 2) there was a similar post about 2 weeks ago, search the archives 3) I have migrated a db using just access and the postgres odbc driver, you can do a cross db query in access ie sth like insert into postgres table, select from access table. Dave On Tue, 2003-12-16 at 10:24, Jason L. van Brackel wrote: > I'm migrating data from a poorly modeled MS Access 2000 DB to newly > developed PosgreSQL 7.4 DB. I'm connecting to the Access database > using a jdbc-odbc bridge driver. I'm connectin the postgreSQL DB > using the pg74jdbc3.jar driver. > > public static void main(String[] args) { > String[] schools; // Array of SchoolCodes > > MigrationUtil migr = new MigrationUtil(); > // Connect to the Access Database > migr.connectToAccess("Access", "C:\\Working\\Access\\Access.mdb"); > // Connect to the PostgreSQL Database > migr.connectToPostgreSQL("PostgreSQL_Test", "cimTux.cim.internal", > "5432"); > // Get Schools List > System.out.println("Getting List of Schools from access.mdb"); > schools = migr.resultSetToStringArray(migr.queryStatement(migr.ODBCConnection, > "SELECT ftno FROM tblmst WHERE ftcode ='SC'")); > // Start the Main Loop > for(int i = 0; i < schools.length; i++) > { > String currentSchool = schools[i]; // current School Code > ResultSet rs = null; // reusable ResultSet variable > String sql = null; // reusable SQL Statement String > int schoolContactID = 0; // current School ContactID > int schoolAddressID = 0; // current School AddressID > int eduOrgID = 0; // current EduOrganization ID > System.out.println("Current School: " + currentSchool); > // Get School information > sql = "SELECT FtDes, LenderAddress1, LenderCity, LenderState, > LenderZip, " + "LenderAddress2, fsch_code, EINNo FROM tblmst WHERE > ftcode = 'SC' AND ftno = '" + currentSchool + "';"; > rs = migr.queryStatement(migr.ODBCConnection, sql); > // Update school address information > System.out.println("Migrating School Address Info"); > try{ > ResultSet addressInfo = null; // ResultSet for Address Info > sql = "SELECT * FROM address;"; > addressInfo = migr.queryStatement(migr.postgreSQLConnection, sql); > addressInfo.moveToInsertRow(); > ..... this is where I get this exception > java.sql.SQLException: No Primary Keys > at org.postgresql.jdbc2.AbstractJdbc2ResultSet.isUpdateable(AbstractJdbc2ResultSet.java:1363) > at org.postgresql.jdbc2.AbstractJdbc2ResultSet.moveToInsertRow(AbstractJdbc2ResultSet.java:697) > at com.cimconsultants.EFRMigration.MigrationUtil.main(MigrationUtil.java:62) > > Here is the queryStatement(Connection, String) Method > > private ResultSet queryStatement(Connection con, String SQLStatement) > { > ResultSet rs = null; > try { > System.out.println("Query: " + SQLStatement); > Statement stmt = > con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, > ResultSet.CONCUR_UPDATABLE); > rs = stmt.executeQuery(SQLStatement); > }catch(SQLException ex) { > System.out.println("Query SQL Exception"); > ex.printStackTrace(); > System.exit(0); > } > return rs; > } > > I'm experienced with Java, but very new to JDBC and PostgreSQL. I'm > using the JDK 1.4, PostgreSQL 7.4, and the binary pg74jdbc3.jar > driver. > > Thanks in advance, > > Jason L. van Brackel > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings > >