• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add a passport image to a form  RSS feed

 
Joe Don
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends, i have a GUI form which i have linked to database successfully. The code is java-based and i use the NetBeans 7.1 IDE. My problem is: how can users add their photo passport image to be stored in the database through the form? Thank you.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on the db you will need a blob column, there is loads of advice in this forum about that (so it must be quite problematic I suppose).

How to get the image from the web page to the servlet is a question for the servlets forum, so i will move you there.

The code will need to stop being netbeans based if you actually want real life users to use it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JspFaq for info on file uploading.
 
Joe Don
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response. As a novice, i need some guide or basically, a link to a good and easy-to-understand tutorial about using BLOB. I do nt quite understand your explanation. Do assist me further, please. Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the FAQ? Do you have specific questions?

There are two steps to this: uploading the file, and then storing it in the database. I'd get the first in place before worrying about the second.
 
shraddha sawant
Greenhorn
Posts: 12
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used javazoom package for uploding files to server.
paste uploadbean.jar path in classpath environment.
I have attached that simple application, you can check.
otherwise, we have to write code, I am also working on it. if you find let me know.
 
Ch Nageswara Reddy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can store the images in the database by using blob in JDBC

Follow this program,



package com.blob.clob;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class StoreImage {
public static void main(String[] args) throws SQLException, FileNotFoundException {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe", "nagesh", "chaduvula");
PreparedStatement pstmt=con.prepareStatement("insert into blob_table values(?, ?)");
File f=new File("D:\\asim.jpg");
FileInputStream fis=new FileInputStream(f);
pstmt.setBinaryStream(1, fis, (int)f.length());
pstmt.setInt(2, 1);
System.out.println("No. of rows affected: "+pstmt.executeUpdate());
System.out.println("Image length: "+f.length());
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!