× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



If I try to "Not specify" the identity column I get

java.sql.SQLException: [SQL0117] Statement contains wrong number of values.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary Thompson
Sent: Wednesday, February 15, 2012 2:20 PM
To: Java Programming on and around the IBM i
Subject: RE: prepared statement and identity column issue

FWiW - When I insert from i into a remote MS Sql table, I do >not< specify the
identity column in the INSERT column list, and, of course, there is no
parameter value for that column.

So, maybe:
INSERT INTO Cutsheet00 (col2, col3, col4) VALUES(?,?,?)


-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Smith, Mike
Sent: Wednesday, February 15, 2012 12:11 PM
To: 'java400-l@xxxxxxxxxxxx'
Subject: prepared statement and identity column issue

I am writing a program a little java program that reads an ACCESS database and writes the records to a the I.

I had this program working, but then I decided to add an identity column to the database on the I.

Now I can't figure out how to get the records written.

Snippet of what I'm doing



pstmt= condb.prepareStatement("INSERT into Cutsheet00 VALUES (?,?,?,?)");

while (rs.next())
{
int order = rs.getInt(1);
String house = rs.getString(2);
String street = rs.getString(3);


pstmt.setInt(1,order);

if (house == null)
house = " ";
pstmt.setString(2,house);
pstmt.setString(3,street);
pstmt.executeUpdate();
}

File cutsheet00 has 4 fields, identity column, order, house, street) I have tried various combinations, but nothing I do lets me get the identity column added.


Thanks for any help

Mike

NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.



--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.

NOTICE: This message, including any attachment, is intended as a confidential and privileged communication. If you have received this message in error, or are not the named recipient(s), please immediately notify the sender and delete this message.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.