• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert image directly from webcam into database

 
abraham kalu ume
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please friends I want to know how I can insert image that is display from the webcam on a Jpanel into a database. I don't want to upload of attach the picture just want it directly from webcam to database.

Please expecting your reponds.
Thanks.
 
Dave Tolls
Ranch Hand
Posts: 2112
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just so we know where you are at at the moment.

You already have the image displayed in a JPanel?
What does that code look like?

Where is your database?
Have you got a connection between your Java app and the database?

Is this a desktop application?
 
abraham kalu ume
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes the app is a desktop app.

I've been able to insert user inputed data to database.

Below is my code. Moreso I've been able to capture image from webcam and can also save it in a folder. But the problem I'm having is to insert the captured image(from webcam) into database.

Please I need the help because I have limited time for the app.

I'm using java to write the code.




 
Campbell Ritchie
Sheriff
Posts: 51468
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always use code tags; I have added them for you this time, and broken the worst of the long lines, and doesn't it look better now
 
Carey Brown
Bartender
Posts: 1966
24
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To store an image into a database you'll need to use the SQL type of 'BLOB' (binary large object). Alternatively you could store the image in a file and store the file name in the database.
 
Paul Clapham
Sheriff
Posts: 21588
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Java side you can do this:

Create a PreparedStatement which contains a suitable INSERT statement (or UPDATE, if that's what you need). Then create an InputStream from which the image can be read. Use one of the PreparedStatement's setBinaryStream methods to connect that input stream to the SQL statement, and finally call the PreparedStatement's execute() method to execute the SQL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic