Uploading file to mysql database
Hi guys
I m working on fedora core 6 mysql server and using java technology jdbc driver com.mysql.jdbc.Driver for connecting to mysql server.
I want to upload all types of files into database. Please give me idea or tips to accomplish this using java.
Awaiting for your replies.
Thanking you
shrinidhi
1) Please in FUTURE JDBC related questions should be posted into the JDBC forum.
2) Blob
3) Google
According to google you are the 1,750,001st person to ask this question so honestly if you looked for two seconds you'll find plenty of answers.
Hi,
here is an idea,
Full example i send to your mail id which i took from your profile (Modify for your purpose),
PreparedStatement pst = con.prepareStatement("insert into file values(?)");
//logo path is a value which is come from file browser
FileInputStream fis=new FileInputStream(request.getParameter ( "path" ) );
byte[] b= new byte[ fis.available()+1];
fis.read(b);
pst.setBytes(1,b);
pst.executeUpdate();
pst.close();