tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Fowler <>
Subject [OFF TOPIC] Re: how to read a text file and store into mysql databse --JAVA
Date Tue, 10 Aug 2004 16:05:48 GMT
Hi Maruthi,

This should do what your after. The variable file is obviously the
file you want to insert into the database.

PreparedStatement prestate = websiteDBCon.prepareStatement("" +
                             "INSERT INTO Collateral (AccountTypeID," +
                             "Document" +
                             "VALUES (?)");

//make sure the statement is clear

//add the file to the statement
prestate.setBinaryStream(1,                        //parameter reference
			new FileInputStream(file), //file to insert
			(int) file.length());      //length of file

//excute the statement

Hope this helps!

-Mike Fowler
"I could be a genius if I just put my mind to it, and I,
I could do anything, if only I could get 'round to it"

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message