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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:14:19+00:00 2026-05-29T07:14:19+00:00

I am trying to insert a file from a java application into a mysql

  • 0

I am trying to insert a file from a java application into a mysql table.

The call to the mapper completes without any exception, but at the end I don’t find any records inside the table.

Maybe there is something wrong with the way I am mapping a file content to the blob field?

This is the bean:

public class CustomFile {
private int id;
private String title;
private String fileName;
private String fileType;
private String fileSize;
private byte[] fileContent;
private String fileExtension;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getTitle() {
    return title;
}

public void setTitle(String title) {
    this.title = title;
}

public String getFileName() {
    return fileName;
}

public void setFileName(String fileName) {
    this.fileName = fileName;
}

public String getFileType() {
    return fileType;
}

public void setFileType(String fileType) {
    this.fileType = fileType;
}

public String getFileSize() {
    return fileSize;
}

public void setFileSize(String fileSize) {
    this.fileSize = fileSize;
}

public byte[] getFileContent() {
    return fileContent;
}

public void setFileContent(byte[] fileContent) {
    this.fileContent = fileContent;
}

public String getFileExtension() {
    return fileExtension;
}

public void setFileExtension(String fileExtension) {
    this.fileExtension = fileExtension;
}

 }

And this is the mapping:

<insert id="saveFile" parameterType="CustomFile">

    INSERT INTO file SET
    Title = #{title},
    File_Name = #{fileName},
    File_Type = #{fileType},
    File_Size = #{fileSize},
    File_Content = #{fileContent,jdbcType=BLOB},
    File_Extension = #{fileExtension}

</insert>

this is the log4j log:

2012-02-04 20:14:20,656 DEBUG java.sql.Connection.debug:27 - ooo Connection Opened
2012-02-04 20:14:22,128 DEBUG java.sql.PreparedStatement.debug:27 - ==>  Executing: INSERT INTO file SET Title = ?, File_Name = ?, File_Type = ?, File_Size = ?, File_Content = ?, File_Extension = ? 
2012-02-04 20:14:22,135 DEBUG java.sql.PreparedStatement.debug:27 - ==> Parameters: Test(String), 294435318.jpg(String), image/jpeg(String), 10028(String), java.io.ByteArrayInputStream@13105f32(ByteArrayInputStream), image/jpeg(String)
2012-02-04 20:14:30,113 DEBUG java.sql.Connection.debug:27 - xxx Connection Closed

Thanks!

  • 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-29T07:14:19+00:00Added an answer on May 29, 2026 at 7:14 am

    Perhaps you are failing to commit your insert? May we see the code where you create the SqlSession?

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

Sidebar

Related Questions

I'm trying to insert a file path into an empty MySQL table with PHP
I am trying to INSERT INTO a table using the input from another table.
I'm trying to insert text into a MySQL DataBase from a form using PHP.
I'm trying to insert some data into a table from a csv document which
So basically I have been trying to insert columns into my third table from
I'm trying to insert some import lines into a python source file, but i
I was trying to insert new data into an existing XML file, but it's
I am trying to take a rather large CSV file and insert it into
I am trying to import a csv file to insert data into an existing
I read from source.sql ( sql script ) file INSERT INTO `Tbl_abc` VALUES (1111,

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.