MySQL Forums :: Connector/JDBC and Java :: Using LOAD DATA INFILE with byte stream

Advanced Search

Re: Using LOAD DATA INFILE with byte stream
Posted by: Mark Matthews ()
Date: November 30, 2005 08:30PM

Mark Matthews wrote:
> Carlo Bos wrote:
> > Can you please help me with the following
> > problem:
> >
> > I'm currently looking at the LOAD DATA
> > statement to load a csv file into a table.
> This
> > statement requires a filename and the
> database to
> > access this file on the filesystem. (I've
> used
> > this statement successfully on my
> development
> > machine)
> >
> > However in the production environment, the
> csv
> > file is received through a web form on a
> JBoss
> > 4.0.2 server and the MySQL 4.1 server resides
> on a
> > different machine.
> >
> > So to solve this issue I'm wondering if there
> a
> > way to specify a byte stream through a jdbc
> > connection to accomplish this. Meaning that
> the
> > uploaded file does not need to be created on
> the
> > server, but is directly streamed to the
> database.
> > I'd really like to use the automatic parsing
> > ability that comes with the LOAD DATA INFILE
> > command though. Any solution is welcome!
> >
> > So in short: I'd like an uploaded csv file to
> be
> > imported to a MySQL table which resides on a
> > different machine than the web app server.
> >
> > Code examples are appreciated.
> >
> > Thanks,
> > Carlo
> Carlo, there isn't directly support for it, as
> there's no easy way to specify the stream file
> descriptor in SQL. However, if you add
> "allowUrlInLocalInfile=true" to your JDBC URL, the
> "path" to LOAD DATA INFILE LOCAL can be a URL,
> which could be made to wrap your input stream in
> some way.
> You could also always hack something into
> MySQLIO.sendFileToServer() to grab a stream from a
> thread local, since we don't currently have plans
> for adding this functionality ourselves (at least
> until we figure out a nice way to do it).
> -Mark


Ah, also noticed that you weren't using LOAD DATA LOCAL INFILE, which would work without any "hacks", since you could have the file "local" to the JDBC driver. The JDBC driver then streams this file to the MySQL server.


Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools

Options: ReplyQuote

Subject Written By Posted
Using LOAD DATA INFILE with byte stream Carlo Bos 11/30/2005 02:59PM
Re: Using LOAD DATA INFILE with byte stream Mark Matthews 11/30/2005 08:29PM
Re: Using LOAD DATA INFILE with byte stream Mark Matthews 11/30/2005 08:30PM
Re: Using LOAD DATA INFILE with byte stream Carlo Bos 12/05/2005 01:25PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.