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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:57:26+00:00 2026-05-28T06:57:26+00:00

The web application I’m currently developing supports CSV export from (using SELECT INTO OUTFILE)

  • 0

The web application I’m currently developing supports CSV export from (using SELECT INTO OUTFILE) and import to (using LOAD DATA INFILE) MySQL server to maintain huge data sets that are extremely expensive to be processed using SELECT and bulk INSERT statements in Java code (processing result sets, string encoding stuff, business logic heritage, etc). These CSV files are not application-driven, so they just represent the raw tables content from the MySQL database. But as far as I understand this approach is good only if I have local files, so both web application server and mysqld must run at the same machine.

The application configuration can specify a remote database connection. That obviously means that uploaded CSV files are stored somewhere locally at the machine where the web application is running on, so I cannot specify the data file location in MySQL LOAD DATA INFILE statement. (The same scenario is for a CSV download request). So, what I’m trying to find is a way to specify the CSV file “virtually” – using a I/O stream that could be processed by JDBC and MySQL, similarly to blobs management etc.

Does JDBC/MySQL support this technique for CSV files for import and export?

Thanks in advance.

  • 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-28T06:57:26+00:00Added an answer on May 28, 2026 at 6:57 am

    You can run LOAD DATA INFILE using the LOCAL option which will then load the CSV file from where the MySQL JDBC Client is running from, using com.mysql.jdbc.Statement#setLocalInfileInputStream. For example:

    // conn is an existing java.sql.Connection to a remote server
    try (Statement st = conn.createStatement()) {
        String localCsvFileSpec = "C:/Users/Jamie/Desktop/foo.csv";  // on this machine
        ((com.mysql.jdbc.Statement) st).setLocalInfileInputStream(
                new FileInputStream(localCsvFileSpec));
        st.execute(
                "LOAD DATA LOCAL INFILE '(placeholder)' " + 
                "INTO TABLE table01 " +
                "COLUMNS TERMINATED BY ',' " +
                "(id, txt) " + 
                "");
    }
    

    See this post for more information.

    Unfortunately, it appears that you can’t use SELECT INTO OUTFILE to export files anywhere other than your database server, from this answer on Stack Overflow.

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

Sidebar

Related Questions

My web application is using the asp.net cache object to store data from the
My web application (MonoRail, Windsor, ActiveRecord) has a Startable import service and one or
The web application that I am developing right now has something called quiz engine
In web application using asp.net, i am using repeater control, in ItmeCommand event i
Our web application (.net/C#) formats currency amounts using amount.ToString(c), shown localized to a few
A web application I am developing needs to perform tasks that are too long
In web application[asp.net], i am using telerik grid control, i am bind the data
The web application that I am developing right now has something called quiz engine
My web application is composed of several Visual Studio projects. It currently runs fine
My web application is using Spring Security but it returning a BadCredentialsException when processing

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.