Store Pictures in Oracle databases

Please anybody can tell about that, how to store pictures or images in oracle database 9i.

To store pictures in your database you need a table with a BLOB column and one application in oracle forms or java to load them. This code is a web servlet to display photos in a web page:
package kas.web.interfases.metrics;
* GetFoto.java
import java.io.*;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import oracle.jdbc.driver.OracleDriver;
public class GetFoto extends HttpServlet {
public GetFoto() {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
doPost(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{   System.out.println("test");
try {
DriverManager.registerDriver(new OracleDriver());
catch(Exception exception) { }
try {
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.21.0.96:1521:PRESIDEN", "kas", "kas");
Statement stmt = conn.createStatement();
if(conn != null) {
String cod = request.getParameter("cod");
if(cod == null)
cod = "2";
String sql = "SELECT emf_foto1 FROM pla_emf_empfoto WHERE emf_codemp=" + cod;
if(!cod.equals("")) {
ResultSet rset = stmt.executeQuery(sql);
try {
if(rset.next()) {   ////System.out.println("test2");
Blob ablob = rset.getBlob("emf_foto1");
response.setContentType("image/gif");
OutputStream out = response.getOutputStream();
long bloblen = ablob.length();
int buffersize = (int)bloblen;
int bytesRead = 0;
byte b[] = new byte[buffersize];
InputStream is = ablob.getBinaryStream();
while((bytesRead = is.read(b)) != -1)
out.write(b, 0, bytesRead);
is.close();
response.flushBuffer();
finally {
rset.close();
conn.close();
catch(SQLException sqlexception) {
System.out.println(sqlexception.toString());

Similar Messages

  • Pictures In Oracle Database

    Hi,
    I want to store images into oracle database but i dont know how. I have a form from developer and a database.
    Please help.
    Grace

    To store pictures in your database you need a table with a BLOB column and one application in oracle forms or java to load them. This code is a web servlet to display photos in a web page:
    package kas.web.interfases.metrics;
    * GetFoto.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import oracle.jdbc.driver.OracleDriver;
    public class GetFoto extends HttpServlet {
    public GetFoto() {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    doPost(request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {   System.out.println("test");
    try {
    DriverManager.registerDriver(new OracleDriver());
    catch(Exception exception) { }
    try {
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@172.21.0.96:1521:PRESIDEN", "kas", "kas");
    Statement stmt = conn.createStatement();
    if(conn != null) {
    String cod = request.getParameter("cod");
    if(cod == null)
    cod = "2";
    String sql = "SELECT emf_foto1 FROM pla_emf_empfoto WHERE emf_codemp=" + cod;
    if(!cod.equals("")) {
    ResultSet rset = stmt.executeQuery(sql);
    try {
    if(rset.next()) {   ////System.out.println("test2");
    Blob ablob = rset.getBlob("emf_foto1");
    response.setContentType("image/gif");
    OutputStream out = response.getOutputStream();
    long bloblen = ablob.length();
    int buffersize = (int)bloblen;
    int bytesRead = 0;
    byte b[] = new byte[buffersize];
    InputStream is = ablob.getBinaryStream();
    while((bytesRead = is.read(b)) != -1)
    out.write(b, 0, bytesRead);
    is.close();
    response.flushBuffer();
    finally {
    rset.close();
    conn.close();
    catch(SQLException sqlexception) {
    System.out.println(sqlexception.toString());

  • Help: How to open wrapped store procedure on oracle database

    Dear Gurus,
    how to open the wrapped store procedure on oracle database?
    anyone can help me...?
    reply me soon
    take care

    Any other way so that I can see the flow of data that written on wrapped store procedure?You need to see the source code which has keeped outside of database. Read a wrapped code is not common for humans...
    reply me asap If you want an asap answer, raise a SR for oracle support, not through a forum which is based on volunteers.
    Nicolas.

  • How to store image in oracle database and retrieve

    Hi i want to store a image in oracle database, user will select the image and i want tht image to store in database in java/jsp can anybody help

    try the following in yr app
    try{
    File fileObject = new File("img path");
    FileInputStream fisObject = new FileInputStream(fileObject);
    PreparedStatement pstmt =
    conn.prepareStatement("insert into IMG_TABLE values (?,?)");
    pstmt.setString(1,fileObject.getName());
    pstmt.setBinaryStream(2,fisObject,(int)fileObject.length());
    pstmt.executeUpdate();
    catch(SQLException se)
    se.printStackTrace();
    catch(Exception ee)
    ee.printStackTrace();
    }

  • Need help on interface to store images into oracle database using forms 6i

    i am using forms 6i and oracle 8i. i am able to store .jpg and other picture files into data base.now my problem is how show and store the CAD/CAM drawings using forms. can any one help me please. is higher version is providing any new facility for this purpose?
    thank you

    thanks for your help.
    i am using client/server based application and cad/cam software was also installed on it. helper application means, the cad/cam software should provide some controls to view the drawings in other applications? am i correct.

  • HOW TO Store  Vectors in oracle database

    Hello everyone,
    In my project, Iam having a Jtable WITH MULTIPLE ROWS AND COLUMNS as my GUI, INWHICH USER TYPES HIS VALUES. THE NUMBER OF ROWS AND COLUMNS ARE SELECTED BY USER WHICH ARE DYNAMIC.
    THE PROBELM IS I DON'T KNOW HOW TO STORE EACH ROW VALUES IN DATABASE.I HAVE TO TAKE EACH ROW VALUES AND STORE THEM IN DATABASE. I TAKE EACH ROW AND STORE IT IN A VECTOR. AFTER THAT ONLY THE PROBLEM RAISES.
    IS THERE ANY WAY TO STORE VECTORS IN DATABASE.
    PLEASE HELP ME IN SOLVING THIS PROBLEM.
    THANK YOU.

    Bathina,
    A "JTable" is usually used to visualize a database table. You seem to want to store a "JTable" in your database. It looks like you may not know much about relational databases.
    If you haven't already done so, I suggest reading the "Oracle Concepts" manual. It is available from:
    http://tahiti.oracle.com
    Good Luck,
    Avi.

  • How to store Unicode in Oracle database ?

    I have a J2EE application and currently we are storing the Unicode data in amp;#xxx; format.
    The browser can display this properly but the java swing application cannot. So I need to convert this to \uxxxx format.
    Is it advisable to store the data in the d/b in the \uxxxx format or amp;#xxx; format ? Advantages ? Disadvantages ?
    The database is setup for UTF-8.
    Thanks

    Not really sure what you are asking the conversion from whatever character set to Unicode should occur without thought to decimal or hex. What is the insert statement or method you are using to get the data ineserted into the database?

  • MSSQL 2005 to Oracle Database Conversion Issue

    Hi Experts,
    We have a requirement where we need to fetch data from MSSQL2005 and store it in Oracle DataBase.
    Could you all please let me know which KM module i need to import to achieve it.
    Cheers,
    Andy

    Andy
    There are a number of options. You should select based on the volume of data and platform, and flexibility of your architecture etc
    - At the simplest level, you could use the LKM SQL to Oracle, which will issue a SELECT on the source and do INSERTS on the target (using prepared statements etc, so not horrendous)
    - You could use the a bulk loading methodology - by using SQLUNLOAD (or bcp) and then load into Oracle using External Tables or SQLLOADER, which will probably be the fastest solution. (I created a KM which generates all the right code to load the data that way, but without a staging area, you can find it here
    If you want a staging area table etc, then you could modify the code in that KM to be an LKM rather than an IKM.

  • How To Store pdf or doc file in Oracle Database using Java Jdbc?

    can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.

    Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
    for Adding PDF in DB i used image.jsp
    Database table structure (table name. pictures )
    Name Null? Type
    ID NOT NULL NUMBER(11)
    IMAGE BLOB
    <%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%
    try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
         PreparedStatement ps,pstmt,psmnt;
         ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
    File file =
    new File("D:/info.pdf");
    FileInputStream fs = new FileInputStream(file);
    ps.setInt(1,4);
    ps.setBinaryStream(2,fs,fs.available());
    int i = ps.executeUpdate();
    if(i!=0){
    out.println("<h2>PDF inserted successfully");
    else{
    out.println("<h2>Problem in image insertion");
    catch(Exception e){
    out.println("<h2>Failed Due To "+e);
    %>
    O/P: PDF inserted successfully
    i tried to display that pdf using servlet. i am giving the code below.
    import java.io.IOException;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class DispPDF extends HttpServlet {
         * The doGet method of the servlet. <br>
         * This method is called when a form has its tag value method equals to get.
         * @param request the request send by the client to the server
         * @param response the response send by the server to the client
         * @throws ServletException if an error occurred
         * @throws IOException if an error occurred
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              //response.setContentType("text/html"); i commented. coz we cant use response two times.
              //PrintWriter out = response.getWriter();
              try{
                   InputStream sPdf;
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
                        PreparedStatement ps,pstmt,psmnt;
                   psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
                        psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
                   ResultSet rs = psmnt.executeQuery();
                        if(rs.next()) {
                   byte[] bytearray = new byte[1048576];
                        //out.println(bytearray);
                        int size=0;
                        sPdf = rs.getBinaryStream(1);
                        response.reset();
                        response.setContentType("application/pdf");
                        while((size=sPdf.read(bytearray))!= -1 ){
                        //out.println(size);
                        response.getOutputStream().write(bytearray,0,size);
                   catch(Exception e){
                   System.out.println("Failed Due To "+e);
                        //out.println("<h2>Failed Due To "+e);
              //out.close();
    OP
    PDF-1.4 %âãÏÓ 2 0 obj <>stream xœ+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2‹ŠKüsSŠSŠS4C²€ê P”kø$V㙂GÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
    plz help me out.

  • How to store image in the oracle database 10.2.

    Hi.,
    I am working on 10g ids. I have designed a form where there are two fields. Name and picture.
    I want to keep details of the person with their photo.
    I can simply put name but how to insert image in the picture field??
    can you suggest ??
    Thanks.
    Shyam

    Hi
    To store your binary images in an Oracle database, you will need to create a column in your table defined with the BLOB datatype BLOB stands for Binary Large Object. Images from scanners, mpeg files, movie files and so on can all be stored in the BLOB column
    sq>CREATE TABLE test_table (
       id NUMBER,
       image BLOB);then go to
    [http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10796/toc.htm]

  • How to store the rich formated text and screendumps in Oracle database

    Hi,
    I will create an FAQ management system. Users can log into the system, search and view the FAQ and answers. To be intractive, the users can also create new FAQ and add the comments on FAQ answers.
    The FAQ answers have rich formated text and the screendumps in the mid part of the answer. It should be presented in one page during user read/update the answers. How can I store the FAQ answer to Oracle database?
    Best regards,
    Ning

    I used blob to store pictures.
    The FAQ answer is the combination item of formated text and pictures. Can I use it to store?
    If I decided to use blob, how can I present the FAQ answers to the web. How can I edit the answer on the web?
    Thank you very much!

  • Store PDF File in Oracle database 10g

    Hi all,
    I want to store PDF File in Oracle database 10g,
    and then I want to access the pdf file using Oracle Developer 6i
    can anyone tell me how to do this,
    thanks in advance.

    This question has already been posted a lot of times.....
    See the following:
    http://forums.oracle.com/forums/search.jspa?threadID=&q=pdf+file&objID=f82&dateRange=lastyear&userID=&numResults=15
    Greetings,
    Sim

  • How to store India Regional language in oracle database

    Hi,
    Can any guide us how can we store data in Indian regional languages in Oracle database.
    We are using Oracle 10g.
    Also i need to know can we convert existing data in oracle to local language ?
    Thanks

    B_M_A wrote:
    Hi,
    Can any guide us how can we store data in Indian regional languages in Oracle database.
    We are using Oracle 10g.
    Also i need to know can we convert existing data in oracle to local language ?Unicode should help, please see,
    http://docs.oracle.com/cd/E11882_01/server.112/e10729/ch6unicode.htm#i1006691
    Aman....

  • How to store an excel sheet in oracle database

    How can I store excel sheet into oracle.

    Or you could use Heterogenous Services to treat Excel as an external database:
    1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
    2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
    EXCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
    (CONNECT_DATA =
    (SID = EXCL)
    (HS = OK)
    Here SID is the name of data source that you have just created.
    3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = <hs_sid>)
    (ORACLE_HOME = <oracle home>)
    under SID_LIST_LISTENER like:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = d:\ORA9DB)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = ORA9DB)
    (ORACLE_HOME = d:\ORA9DB)
    (SID_NAME = ORA9DB)
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = EXCL)
    (ORACLE_HOME = D:\ora9db)
    Dont forget to reload the listener
    c:\> lsnrctl reload
    4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
    In this file set following two parameters:
    HS_FDS_CONNECT_INFO = excl
    HS_FDS_TRACE_LEVEL = 0
    5- Now connect to Oracle database and create database link with following command:
    SQL> CREATE DATABASE LINK excl
    2 USING 'excl'
    3 /
    Database link created.
    Now you can perform query against this database like you would for any remote database.
    SQL> SELECT table_name FROM all_tables@excl;
    TABLE_NAME
    DEPT
    EMP

  • How to store and retrive images in oracle database

    hi,
    i am interested in storing some students pictures ( photos) into my oracle database, and i want to know since the images are considered as binary data and since BLOB and CBLOB and supported by oracle, how to insert and to select the picture from oracle from my swing-based application?
    does anyone have a complete sample or tutorial doing that well!!
    thx

    Mira este link,
    hay varios articulos interesantes.
    http://www.oracle-base.com/articles/9i/Articles9i.php
    tambien puedes consultar este link
    http://tahiti.oracle.com/pls/db92/db92.homepage
    completa los coampos solicitados con la palabra "Images"
    hay un manual de LOBs muy completo

Maybe you are looking for

  • Re: Be Safe Online: 'Rover' Doesn't Bark Loud Enough to Keep You Safe

    hi, for the last  eight years i have tried everything and every security measure to secure  my computer. i am not a dummy and know what can cause security problems. i have used every available method and had only been able to have a secure computer f

  • 1050c leading edge trims too much

    Hi there, I was trying to figure out if there is a way to make the 1050c trim less of the leading edge when loading a roll.  Every time I load a roll it trims about 4 inches; my old 750 could be loaded to only trim about 1/8 inch. It sure adds up whe

  • Skin of video player in html5

    I have an issue with event videos in my Cp6. The problem is when I try to publish an event video in html, the skin of the player is not converted. Does anybody know if the new Cp7 is able to publish this skin? thanks

  • Rotate image X degrees on WM5

    Hello, I'm creating a programs for a PPC running WM5. The program needs to be able to rotate an image X degrees. But until now I didn't find much that I can use. On a desktop you've got the Advanced graphics and awt.geom. But I can't seem to find any

  • CS4 .indd file association problem

    Hi folks, I'm running a PC with XP and recently upgraded my software from CS3 to CS4. My computer has stopped associating .indd files with InDesign. I've tried to set the file association manually using the Open With command though InDesign doesn't a