Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:51:14+00:00 2026-06-02T19:51:14+00:00

I seem to have a problem with a Java batch insert. What it does

  • 0

I seem to have a problem with a Java batch insert. What it does is inserting values with single quotes into an Oracle table.

java.sql.BatchUpdateException: ORA-12899: value too large for column "P40_001_CM"."PRODUCTDATA"."P_NAME" (actual: 76, maximum: 75)

The fact is that the value I need to insert as P_NAME is :

Best of Hollywood 2 Movie Collector's Pack: Todeszug nach Yuma / Recue Dawn

As you can see (or count if you like); this is exactly 75 characters in length, including the single quote.

Code snippet I am using to handle single quotes :

case Types.VARCHAR:
pstmt.setString(paramIndex, param.getValue().replace("'", "''"));
break;

This approach works, and it does for most of my inserts, but in this particular case it will count the added single quote resulting the entire string to be 76 in length. And thus causes the exception.

Thing is that when I run the insert statement in Squirrel, it just inserts without any problems. And it should, the actual value is still 75 long, only one quote was added to escape another.

Somehow, the internally used OraclePreparedStatement does some kind of check (obviously not a very good one) on the length of the String that is passed and dismisses this before it can actually reach Oracle itself, or so it seems.

How can I fix this ? I can’t be the only one who ever ran into this behaviour ?

Ah, btw, before anyone suggests, yes, I have tried :

`insert into GERMANSTUFF values('Best of Hollywood 2 Movie Collector'||chr(39)||'s Pack: Todeszug nach Zuma / Recue Dawn');`

and
insert into GERMANSTUFF values(translate('Best of Hollywood 2 Movie Collector^s Pack: Todeszug nach Puma / Recue Dawn','^',chr(39)));

and although this works in Squirrel as a direct SQL statement, it only made the String value on which the OraclePreparedStatement throws an error larger. Which seems logical I guess.

I know I can replace the ' by a ^ or just enlarge my destination column, but I don’t consider these ‘solutions’ as the right way to solve this problem. Maybe it’s something simple which I just haven’t seen yet ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:51:15+00:00Added an answer on June 2, 2026 at 7:51 pm

    AFAIK, I don’t think you need to handle the escaping yourself, especially if you’re using PreparedStatement. Just doing the below should take care of the escaping internally.

    pstmt.setString(paramIndex, param.getValue());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seem to have a problem starting my Java app: Exception in thread main java.lang.NoClassDefFoundError:
I seem to have a problem with getting MVC to fill in my custom
I seem to have a problem understanding how to conditionally test a boolean value
I seem to have a tricky problem since the latest ADT update to release
I have a problem which I cant seem to find answer to through searches
I have a problem which i can't seem to find the solution to. I
I seem to have the exact opposite problem than this question on stopping dock
I have a strange problem that I can't seem to solve. I've quite a
I have a pretty basic problem but I can't seem to figure it out...
I have a very simple C# DataTable problem that I cannot seem to wrap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.