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

  • SEARCH
  • Home
  • 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 186913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:43:50+00:00 2026-05-11T15:43:50+00:00

I currently have an application that inserts byte[] into our DB through the use

  • 0

I currently have an application that inserts byte[] into our DB through the use of Spring JDBC [SqlLobValue]. The problem is, this is not a scalable way to take in data, as the server is buffering all the data in memory before writing to the database. I would like to stream the data from the HttpServletRequest Inputstream, but all the constructors I can find for any classes that take an Inputstream as an argument also require the content length as an argument. I do not, and will not, require the user to know the content length when POSTing data to my application. Is there a way around this limitation?

I can find no documentation about what happens if I pass -1 for content length, but my guess is it will throw an Exception. I’m not sure why they couldn’t just have the stream keep reading until the read(…) returns -1, the required behavior of an InputStream.

  • 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. 2026-05-11T15:43:51+00:00Added an answer on May 11, 2026 at 3:43 pm

    I presume you meant ‘InputStream’ rather than ‘OutputStream’. I tried this out, but I was having bigger problems with my JDBC driver, so I am unsure if this actually works.

    InputStream inputStream = httpServletRequest.getInputStream();  int contentLength = -1; // fake, will be ignored anyway SqlLobValue sqlLobValue = new SqlLobValue(     inputStream,     contentLength,     new DefaultLobHandler() {         public LobCreator getLobCreator() {             return new DefaultLobHandler.DefaultLobCreator() {                 public void setBlobAsBinaryStream(PreparedStatement ps, int paramIndex, InputStream binaryStream, int contentLength) throws SQLException {                     // The contentLength parameter should be the -1 we provided earlier.                     // You now have direct access to the PreparedStatement.                     // Simply avoid calling setBinaryStream(int, InputStream, int)                     // in favor of setBinaryStream(int, InputStream).                     ps.setBinaryStream(paramIndex, binaryStream);                 }             };         }     } );  jdbcTemplate.update(     'INSERT INTO foo (bar) VALUES (?)',     new Object[]{ sqlLobValue } ); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 107k
  • Answers 107k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Mapping == association == link == reference. May 11, 2026 at 9:05 pm
  • Editorial Team
    Editorial Team added an answer I would recommend using the Remote API; you can edit… May 11, 2026 at 9:05 pm
  • Editorial Team
    Editorial Team added an answer Personally, I run everything inside GNU screen. This gives me… May 11, 2026 at 9:05 pm

Related Questions

I am writing an application that logs status updates (GPS locations) from devices to
I have an Oracle table which contains event log messages for an application. We
I have a situation in which a CSV is uploaded to my application and
Is there a way to query the current DATEFORMAT SQLServer 2005 is currently using
I have an application I am working on that will need the use of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.