This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes Problem with inserting into MS Access Memo field. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem with inserting into MS Access Memo field." Watch "Problem with inserting into MS Access Memo field." New topic
Author

Problem with inserting into MS Access Memo field.

Stavya Grover
Greenhorn

Joined: Apr 22, 2011
Posts: 3
Hi, I have an ODBC named store in MS Access. There's a table called desc which has bookId(Number) and summary(Memo).
My code to insert data into the table is:




The output which I am getting in Netbeans is:

Errors!
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
BUILD SUCCESSFUL (total time: 0 seconds)

Any help,please?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

Have you tried the following:
- psumm.setString(2, summary);
- psumm.setCharacterStream(2, new StringReader(summary));
- psumm.setClob(2, new StringReader(summary));

Or, for unicode:
- psumm.setNString(2, summary);
- psumm.setNCharacterStream(2, new StringReader(summary));
- psumm.setNClob(2, new StringReader(summary));

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Stavya Grover
Greenhorn

Joined: Apr 22, 2011
Posts: 3
1. The table in MS Access cannot have a name desc, so changed the name,still, the above are not working.
2. setString gives : General error
3.psumm.setCharacterStream(2, new StringReader(summary)); gives: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
4.psumm.setClob(2, new StringReader(summary)); also gives: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect


Is there a way to convert the string to a Clob and then use setClob()? And if I am using CLOBS, the data type in MS Access should be what?
I've got a project to submit tomorrow, this is taking too much time! Can't find the solution, I just need to store looooooong strings in MS Access. Suggest a way,please!

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

A few more attempts:

You can also try to convert the column to Text. If I recall correctly that can handle large amounts of text as well.
Stavya Grover
Greenhorn

Joined: Apr 22, 2011
Posts: 3
It worked!

I just had to change the table name to something else than desc. The code I posted worked with memo.
I'll try out your suggestions also. Thanks!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19679
    
  18

You're welcome.
 
 
subject: Problem with inserting into MS Access Memo field.