I am trying to insert a PDF file into the database and to retrieve it. I can insert the pdf successfully. Kindly send me the sample code for retreving the pdf file from the database.
Thanks/Regards
Aravind Prasad
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
posted
0
Sorry The code i am using is written below.
Please assist at the earliest.
Thanks/Regards APrasad
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
What is the problem with the code - doesn't it work?
it is nt working. it is creating a file with pdf extension but no data inside it.
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
posted
0
This is the complete code. With this code, it is inserting the pdf in the database and also retreving. The file size which is inserting is same as file size retreving. But it is displaying only a blank pdf document. (meaning the pages are empty)
Hi Thankyou.. my problem is solved. The correct code is given below for others to refer.
Cheers!!! Aravind Prasad
chandra reddy pandillapalle
Greenhorn
Joined: Mar 31, 2008
Posts: 6
posted
0
if i am using the above code for uploading pdf file into databse it is giveing following error
java.sql.SQLException: Io exception: Char array not long enough: javaCharsToUtf8Bytes at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061) at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589) at PDFFile.insertFile(PDFFile.java:46) at PDFFile.main(PDFFile.java:79)
chandra reddy pandillapalle
Greenhorn
Joined: Mar 31, 2008
Posts: 6
posted
0
please any one give reply what is the problem in that code Thanks, Chandra
Did you use the same type of column that Aravind Prasad used? [ March 31, 2008: Message edited by: Paul Clapham ]
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
posted
0
Reddy Bhai.
My table structure is given below. Please go thru this
This code will work perfectly. Also use longblob instead of Blob
Kindly update also
Regards
chandra reddy pandillapalle
Greenhorn
Joined: Mar 31, 2008
Posts: 6
posted
0
this is my table structure i am also using same CREATE TABLE IMAGE ( IMG BLOB )
please let me know why it is giving error
joseph okon
Ranch Hand
Joined: Dec 07, 2004
Posts: 63
posted
0
Hi Am using the same codes as above it is not giving me the required output that is it is not writing to the folder i want it to write to, what can be wrong with my codes please i need help thanks
this is my code:
Perfection is for God only
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
posted
0
Hi Joseph,
Could you please kindly post your table structure also. Also the value you are passing thru request.getParameter().
Regards
Aravind
joseph okon
Ranch Hand
Joined: Dec 07, 2004
Posts: 63
posted
0
Hi Joseph, Could you please kindly post your table structure also. Also the value you are passing thru request.getParameter(). Regards Aravind
this is my table structure:
mysql> show tables; +-------------------+ | Tables_in_filesdb | +-------------------+ | bigfiles | | login | +-------------------+ 2 rows in set (0.06 sec) mysql> desc bigfiles; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | file_id | varchar(15) | YES | | NULL | | | file_img | longblob | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.19 sec) thanks for your assistance Best regards joseph
joseph okon
Ranch Hand
Joined: Dec 07, 2004
Posts: 63
posted
0
Searchfile.jsp
Search.jsp code:
Aravind Prasad
Ranch Hand
Joined: Dec 28, 2005
Posts: 258
posted
0
Hoi Joseph
Try to modify the query you are using from
to
Also pass the parameter value as the file_id value.
Regards
Aravind Prasad
joseph okon
Ranch Hand
Joined: Dec 07, 2004
Posts: 63
posted
0
Aravind Prasad i have try the changes you made but it is still not doing it?? it produces null when run. i am short of idea can you write a piece of code to get parameter from html/jsp and retrieve the corresponding item from the database then place it in a folder for me? thanks