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 7005475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:21:19+00:00 2026-05-27T21:21:19+00:00

I have problem for bulk insert of the file.I am saving the multiple record

  • 0

I have problem for bulk insert of the file.I am saving the multiple record in mysql database with GWT from server side helper class.In that helper class, I have method for saving multiple record of the report object which is my domain class.Lets see code snippet below

while (iterator.hasNext()) {
    Report report = (Report) iterator.next();
    preparedStatment.setString(1, report.getTitle());
    preparedStatment.setString(2, report.getReportAbstract());
    preparedStatment.setString(3, report.getUrl());
    preparedStatment.setDate(4,(java.sql.Date) report.getPublishDate());
    preparedStatment.setString(5, report.getAuthor());
    preparedStatment.setString(6, report.getPublisher());
    preparedStatment.setDouble(7, report.getPrice());
    preparedStatment.setString(8, report.getCurrency());
    preparedStatment.setBoolean(9, report.isPurchase());
    **preparedStatment.setBinaryStream(10, inpStream,(int)inputFile.length());**
    preparedStatment.setString(11, report.getMimeType());
    preparedStatment.setBoolean(12, report.isDownload());
    preparedStatment.setLong(13, report.getReportSource());
    preparedStatment.setDate(14, new java.sql.Date(date.getTime()));
    preparedStatment.setBoolean(15, report.isDeleted());
    preparedStatment.addBatch();
}    
int[] updateCounts = preparedStatment.executeBatch();
connection.commit();

In the above code,the line in bold font for sending file for insert.I looping and inserting one by one record.but It only insert file for first record in database and for remaining record that field is empty i.e no file insertion but all fields are inserted properly.I stuck here for inserting file field for all record.
Can anybody please help me on this?

  • 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-05-27T21:21:20+00:00Added an answer on May 27, 2026 at 9:21 pm

    I don’t know your full code. You can try the following code,

    File TryFile = new File("yourFileName.txt");
    int TryFileLength = (int) TryFile.length();
    InputStream TryStream = (InputStream) new FileInputStream(TryFile);
    

    and then in the Iterator just put the below code as a static one and lets see. If it works fine then pbm with your code only. Check the code before the Iterator.

    preparedStatment.setBinaryStream(10, TryStream,TryFileLength);

    Correct me if i’m wrong..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database that I'm trying to populate from a text file.
How with SQL server bulk insert can I insert into multiple tables when there
I have a test server that uses data from a test database. When I'm
I have problem when I try insert some data to Informix TEXT column via
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I need to delete many rows from sql server 2008 database, it must be
I'm using OPENROWSET(BULK ...) to insert the contents of a file into my table.
I'm performing a bulk insert with an ADO.NET 2.0 SqlBulkCopy object from a C#
I have two methods from which first i am using to insert data and
I have a custom import tool which bulk-insert the data in temp (421776 rows).

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.