Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Store post in mysql database  RSS feed

 
priyanshi bhardwaj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am doing a project in which i am making a online news portal for my college website will allow user to upload college daily activities i.e any sort of notices etc so the data could be in the form of images as any .jpg format or any other .txt file or any pdf so how to store them in
the database eg could be facebook post section allows us to upload
images or write anything on timelines so i want the

"simpler version of post section in facebook "

. so how can i store all the posts in mysql database.
 
Swastik Dey
Rancher
Posts: 1784
14
Android Eclipse IDE Java Java ME
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know about JDBC, the first towards storing data to database using java.  As far as storing different type of file formats is concerned, there can be two ways.

#1.  Create the files physically and store the path in db.

or

#2.  Use LOB/BLOB data types to store the raw file data in database itself.
 
priyanshi bhardwaj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:Do you know about JDBC, the first towards storing data to database using java.  As far as storing different type of file formats is concerned, there can be two ways.

#1.  Create the files physically and store the path in db.

or

#2.  Use LOB/BLOB data types to store the raw file data in database itself.

thanks for guidance
i want to do the second one
can you please give me an example or any link to which i can refer to do so
 
priyanshi bhardwaj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please take a look at this

backend
there are no errors but data is not getting inserted in database.

 
Paul Clapham
Sheriff
Posts: 22215
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first problem is that you put that code into a JSP. That makes it hard to test. It also (as you can see) makes it hard to read. I'd suggest for a start that you get that code out of a JSP and into a servlet, or some similar Java class, where it belongs. Forward to the JSP when your updates are done.

Having said that: your HTML which submits the request appears to be sending a multipart/form-data request. In other words, a file upload. But you don't have any code which handles the uploaded file. You may think the code with the File object does that but it doesn't.

And anyway you have this statement:



But you don't have a form parameter named "uploadForm" so a lot of code after that statement will be skipped. I don't know how much because the inconsistent indentation of the code makes it very hard to find the closing bracket, but I haven't even tried because the whole thing needs to be redone to handle file uploads properly in something other than a JSP.



 
priyanshi bhardwaj
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your guidance. it was helpful for me.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!