NEED TO LEARN JAVA? – 5 FREE JAVA VIDEO COURSES – CLICK HERE – https://goo.gl/7i95F8 — View more videos on my “Java JDBC Tutorial” Playlist: …
Original source
NEED TO LEARN JAVA? – 5 FREE JAVA VIDEO COURSES – CLICK HERE – https://goo.gl/7i95F8 — View more videos on my “Java JDBC Tutorial” Playlist: …
Original source
30 responses to “Java JDBC Tutorial – Part 10: BLOB – Reading and Writing BLOB with MySQL”
Hello
I insert .pdf documents in my database. But when I want to view this pdf, I see some meaningless letters.No problem for .txt documents.I can view .txt documents .How can I deal with this problem?Could you help me please ?
Hello
I sent an email which was about writing blob in Java, If you have time, Could you please check? Thanks
I got the error, " Invalid escape sequence (valid ones are b t n f r " ' \ )"
when specifying the complete path to the sample_resume file… can u tell me how to resolve this?
hey , how to read the blob from the mysql database and and then display it in a jframe? is it possible?
hey, nice video. Very helpful for me.
sir instead of storing the file into the local system, how can we show that file directly from the database onto the JSP page??
Sir plz help me.
Thank you in advanced.
Hey, great video! This has really helped me with understanding the concept of uploading and retrieving files from a database. Thankyou
I am trying to make it graphical where a user logged in can select the file they wish to upload to the database.
I imagine I would have to allow the user to identify their self through a username into a text field. I imagine I need the user to identify the absolute file path? That way on a button, the user will write their file to their record in the database.
How can I go about doing this? Any chance of some guidance and/or source code?
Thanks again, Adam.
Very very very useful! Thanks a bunch!
You've got the best tutorials! Really good work 🙂
verry, verry, verry, thank you
thankz bro, verry helpfull
Hi Chad,
I really appreciate your videos. I am a professional oracle java certified but anyway you are much better than me so i need your advice . Actually i am developing a protocol and in this protocol we need to take files read it one by one and each file byte by byte and for each byte of the file we perform one algorithm . This works good and i have tried it with folder in my pc where there are some files in it . Now my boss wanted for me to try this in amazon cloud and i am wondering how can i do it in amazon since i have no idea how amazon is working. Is it good idea if i just upload my folder in amazon and then run my application or is better to use their databases with some files in it let say 5 images and try to read and write the files from their databases? Actually i am not even sure what kind of databases they use but for sure not mysql since mysql is for small companies but i also doubt if they are using any kind of database which is compatible with jdbc. Please give me a clue what to do with this amazon cloud
very very very tank you guy
you are a genius
Hello chad. While I execute the program, then it completed successfully but the problem while i open the value in editor at workbench then it doesn't show the image tab there… so can u pls help me
Program works the same with direct writing to file from ResultSet with getBytes function -> out.write(rs.getBytes("resume"));,
without this peace of code:
InputStream in = rs.getBinaryStream("reusme");
byte[] buffer = new byte[1024];
if(in.read(buffer)>0) {
out.write(buffer);
}
Q: Is there a specific reason why you do this with peace of code above?
Hi, thank you for sharing this content with a lesson so smoothly.
Professor, I'm also getting the ' java.io.FileNotFoundException: sample_resume.pdf (No such file or directory)' exception
Is this what I have to do to fix it in the Java code?
File file = new File("/Users/juniorsilva/Desktop/sample_resume.pdf");
That's the path to my Mac desktop…
is it possible to store audio files with the size of up 10mb in mysqldatabase??
there is no image tab in my editor in sql, and in the text tab all i see are (C/DD^,n~;>RâæQø^¥*Ï ) somewhat like these characters, what am i doing wrong?
Thanks for ur all videos .. im getting exception…
Reading input file: D:sample_resume.pdf
Storing resume in database: D:sample_resume.pdf
update employees set resume=? where email='jon.doe@foo.com'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'resume' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:939)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5094)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994)
at BlobsAndClobs.WriteBlobDemo.main(WriteBlobDemo.java:45)
I appreciate the tutorial. Would I be able to tailor reading and writing BLOBs to SQLite using your general format? I've always been a bit slow with Java. Thank you.
Champion!
What can I do to handle this Situation
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.Util.getInstance(Util.java:387)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:939)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2073)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2009)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5094)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1994)
at WriteBlobDemo.main(WriteBlobDemo.java:32)
Hi , this is a very good tutorial! however I am unable to see the value of blob in mysql workbench….There is Text and binary tab but there is no image tab.please can you help me solve the problem?
Thank you very much 🙂
Thanks for ur all videos .. im getting exception lyk ==> java.io.FileNotFoundException: sample_resume.pdf(The system cannot find the file specified
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init> (FileInputStream.java:146)
at jdbcdemo.WriteBlob.main (WriteBlobDemo.java: 36)
Hi,
Thanks for your videos. I am getting error and it says Data is too long for column 'resume' . The pdf file size is just 333KB only.
I have to mention the file name including C drive ( complete path), otherwise it gives an error. Would you please let me know where it went wrong. Thanks.
File theFile = new File("c:\data\RAVINDER.pdf");
Output:
Reading input file: c:dataRAVINDER.pdf
Storing resume in database: c:dataRAVINDER.pdf
update employees set resume=? where email='john.doe@foo.com'
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'resume' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3868)
Hello guys, your video is good but I have 2 questions and hope that you can help me.
1. Is pdf file same as blob file ?
2. How can we stream the content pdf file directly to web browser ? This pdf have already stored in the database.
Anyways, thank you very much!
the code works uploading the file. but how can i directly open it in one click in my system gui?
I want to give the user the possibility to choose his file . how can I do that ?
how do I change the path to which the file is being saved? I mean can I mention it explicitly rather than having the program decide the path