How to insert a JPG image in a column of type "image" in sql server 7.0 ??

hi all,
I have a table with 2 columns.
First col is of "Name" and second col is of type "image" .
I am using sql server 7.0 on window 2000.
now i have created table. I want to insert a jpg/gif image in its 2nd column.
How can i do so ? and how i can i read the image object after insertion ?
I am using 2nd col of type "image" and NOT Binary or varBinary.
Any idea will be highly appreciated.
Thanks in advance.
AlwaysJava

hi all,
I have a table with 2 columns.
First col is of "Name" and second col is of type
"image" .
I am using sql server 7.0 on window 2000.
now i have created table. I want to insert a jpg/gif
image in its 2nd column.
How can i do so ? and how i can i read the image
object after insertion ?
I am using 2nd col of type "image" and NOT Binary or
varBinary.
Any idea will be highly appreciated.
Thanks in advance.
AlwaysJavaHi,
Below are some excerpts from my program.. which was doing image insertions and retrievals also.. I have included the image insertion and retrieval portion.. retrieval can be done in more than one ways.. one of them is given.. for very large images, u can read chunks of data from the input stream and write it to the disk. for smaller ones , the given methods work very well..
I tested the program with jdk1.4.0 and aveConnect3.0 driver. on an
SQL server 7 machine from my box running windows 2000... and it worked..
Im not still sure if this is the optimised way.. there can be other more optimised methods..
hope this clears your problem..
cheers,
-Jer
    Connection conn = null;
    Statement stmt = null;
    ResultSet rst = null;
    PreparedStatement pstmt = null;
    FileInputStream fis = null;
    FileOutputStream fop = null;
    File file = null;
    InputStream is = null;
    String createtable = "Create table testtable (name varchar(32),_image image)";
    String inserttable = "Insert into testtable values (?,?)";
    String retrievetable = "Select _image from testtable";
    String droptable = "Drop table testtable";
    String url = "jdbc:AvenirDriver://CodeServer:1433/test";
    conn = DriverManager.getConnection(url,"test","test");
//Create the table
    stmt = conn.createStatement();
    stmt.execute(createtable);
//Insert the file into the table
    file = new File("input.gif");
    fis = new FileInputStream(file);
    pstmt = conn.prepareStatement(inserttable);
    pstmt.setString(1,file.getName());
//Set the filestream to the binary stream into the image in the table
    pstmt.setBinaryStream(2,fis,fis.available());
//Updating the table
    pstmt.executeUpdate();
//clean up the streams and atatement
    fis.close();
    pstmt.close();
// Retrieve the image from the table..
    pstmt =  conn.prepareStatement(retrievetable,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
// execute the Query
    rst = pstmt.executeQuery();
//jump to the first row of the resultset
    rst.beforeFirst();
    rst.next();
//get the inputstream from the image object in the  result set
    is = rst.getBinaryStream(1);
//Writing the data in the inputstream into an outputfile
          //Using getbytes method from the result set
               byte[] bytearray = rst.getBytes(1);
               baos = new ByteArrayOutputStream();
              baos.write(bytearray);
              fop = new FileOutputStream ("output.gif");
              baos.writeTo(fop);
//using the input stream and storing the data in bytearray
//allocating the buffer size to store the data from inpuit stream ... here whole inptstream is allocated..
//(The buffer size can be varied if the file is too large and the reading be..
//  ..done in loop , to read small chunks from the input stream and write it to the file)
    byte[] bytearray = new byte[is.available()];
//to write the data in the byte array into an output file
    baos = new ByteArrayOutputStream();
    baos.write(bytearray);
    fop = new FileOutputStream ("output.gif");
    baos.writeTo(fop);

Similar Messages

  • How to insert the checkbox as a separate column  in alv grid display

    Hi
    How to insert the checkboxes as a separate column  in alv grid display with using the reuse_alv_fieldcatlog_mege.
    example
    matnr    maktx  ersda                 checkbox
    10        books  28/03/2009          checkbox
    Thanks
    chinnu

    Hi,
        Check the following code.
    TYPE-POOLS: slis.
    TYPES:
          BEGIN OF ty_output,
          chk TYPE c,
          number TYPE i,
          name(20) TYPE c,
          END OF ty_output.
    DATA: gt_output TYPE STANDARD TABLE OF ty_output,
          gs_output TYPE ty_output.
    DATA: wa_layout           TYPE slis_layout_alv.
    DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
    After you populate the data, build the field catlog like shown below.
    wa_fieldcatalog TYPE slis_fieldcat_alv.
    wa_fieldcatalog-fieldname = 'CHK'.
      wa_fieldcatalog-outputlen = '3'.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-seltext_m   = 'CHK'.
      wa_fieldcatalog-checkbox = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND  wa_fieldcatalog TO it_fieldcatalog.
    wa_fieldcatalog-fieldname = 'NUMBER'.
      wa_fieldcatalog-outputlen = '10'.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-seltext_m   = 'NUMBER'.
      APPEND  wa_fieldcatalog TO it_fieldcatalog.
      CLEAR  wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'NAME'.
      wa_fieldcatalog-outputlen = '10'.
      wa_fieldcatalog-col_pos = '3'.
      wa_fieldcatalog-seltext_m   = 'NAME'.
      APPEND  wa_fieldcatalog TO it_fieldcatalog.
      CLEAR  wa_fieldcatalog.
      wa_layout-box_fieldname     = 'CHK' .
      wa_layout-box_tabname       = 'GT_OUTPUT' .
    Now call the FM
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = sy-repid
          i_callback_pf_status_set          = 'PF_STATUS'
          i_callback_user_command           = 'USER_COMMAND_GRID'
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
          is_layout                         = wa_layout
          it_fieldcat                       = it_fieldcatalog
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   I_HTML_HEIGHT_TOP                 =
    *   I_HTML_HEIGHT_END                 =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = gt_output
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

  • How to insert large xml file to XMLType column?

    Hi,
    I have a table with one column as XMLType(Binary XML storage option and Free Text Indexing). When i try to insert a large XML as long as 8kb, i'm getting an error ORA-01704:string literal too long.
    Insert into TEST values(XMLTYPE('xml HERE'));
    How to insert large XML values to XMLType column?
    Regards,
    Sprightee

    For a large XML file, you basically have two options - you can load the string directly as an XMLType, or you can load the string as a CLOB and cast it on the database side to an XMLType.
    If you decide to load the XML as XmlType client-side, then you may be interested to know that versions of Oracle after 11.2.0.2 support the JDBC 4.0 SQLXML standard. See the JDBC driver release documentation here:
    http://docs.oracle.com/cd/E18283_01/java.112/e16548/jdbcvers.htm#BABGHBCC
    If you want to load as a CLOB, then you'll need to use PreparedStatement's setClob() method, or allocate an oracle.sql.clob object.
    For versions before 11.2.0.2, you can create an XMLType with a constructor that includes an InputStream or byte[] array.
    HTH
    Edited by: 938186 on Jun 23, 2012 11:43 AM

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

  • How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000

    Post Author: ltkin
    CA Forum: WebIntelligence Reporting
    Hi,
    How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000 ?
    Regards,

    Hi ltkin,
    Unfortunately, it is not possible in Xir2 to create Webi reports from stored procedures.
    Webi reports can only be created from Universe. So in Business Objects XIR3 we can create a special universe that enables Web Intelligence user's to access stored procedures residing in the database. This is the only way that Web Intelligence user's can access stored procedures.
    Please let me know if the above information helps.
    Regards,
    Pavan

  • How to insert a JPG file from file system to Oracle 10g?

    I have developed a schema to store photos as BLOB which store the text description as CLOB original filename, file size.
    I also use ctxsys.context to index TEXT_DESCRIPTION in order to perform Oracle Text Search and it works.
    I would like to insert some JPG file from say C:\MYPHOTO\Photo1.jpg as a new record. How can I do this in SQL PLus and/or Loader?
    How can I retrieve the PHOTO_IMAGE back to the file system using SQL Plus and/or command line in DOS?
    See the following script:
    create user myphoto identified by myphoto;
    grant connect, resource, ctxapp to myphoto;
    connect myphoto/myphoto@orcl;
    PROMPT Creating Table PHOTOS
    CREATE TABLE PHOTOS
    (PHOTO_ID VARCHAR2(15) NOT NULL,
    PHOTO_IMAGE BLOB,
    TEXT_DESCRIPTION CLOB,
    FILENAME VARCHAR2(50),
    FILE_SIZE NUMBER NOT NULL,
    CONSTRAINT PK_PHOTOS PRIMARY KEY (PHOTO_ID)
    create index idx_photos_text_desc on
    PHOTOS(TEXT_DESCRIPTION) indextype is ctxsys.context;
    INSERT INTO PHOTOS VALUES
    ('P00000000000001', empty_blob(), empty_clob(),
    'SCGP1.JPG',100);
    INSERT INTO PHOTOS VALUES
    ('P00000000000002', empty_blob(), 'Cold Play with me at the concert in Melbourne 2005',
    'COLDPLAY1.JPG',200);
    INSERT INTO PHOTOS VALUES
    ('P00000000000003', empty_blob(), 'My parents in Melbourne 2001',
    'COLDPLAY1.JPG',200);
    EXEC CTX_DDL.SYNC_INDEX('idx_photos_text_desc');
    SELECT PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'parents',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),PHOTO_ID ,TEXT_DESCRIPTION
    FROM PHOTOS
    WHERE CONTAINS(TEXT_DESCRIPTION,'cold play',1)> 0
    ORDER BY score(1) DESC;
    SELECT score(1),score(2), PHOTO_ID ,TEXT_DESCRIPTION
    FROM photos
    WHERE CONTAINS(TEXT_DESCRIPTION,'Melbourne',1)> 0
    AND CONTAINS(TEXT_DESCRIPTION,'2005',2)> 0
    ORDER BY score(1) DESC;

    Hi
    You can use the following to insert an image:
    create table imagetab(id number primary key,imagfile blob, fcol varchar2(10));
    create or replace directory imagefiles as 'c:\'
    declare
        v_bfile BFILE;
        v_blob  BLOB;
      begin
        insert into imagetab (id,imagfile,fcol)
        values (3,empty_blob(),'BINARY')
        return imagfile into v_blob;
        v_bfile := BFILENAME ('IMAGEFILES', 'MyImage.JPG');
        Dbms_Lob.fileopen (v_bfile, Dbms_Lob.File_Readonly);
        Dbms_Lob.Loadfromfile (v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));
        Dbms_Lob.Fileclose(v_bfile);
        commit;
      end;
    /

  • How to insert a JPG file into a Table from a Form?

    I create a Schema and a Table as follows:
    SQL> create user myphoto identified by myphoto;
    User created.
    SQL> grant connect,resource to myphoto;
    Grant succeeded.
    SQL> create table myphoto.photo_table
    2 (photo_id varchar2(10) primary key,
    3 photo_content blob);
    Table created.
    I would like to build an Oracle Form with a Text Item to enter the full path and filename to be uploaded and inserted into the photo_table; and a Push Button to insert the jpg file into the photo_table.
    Can any one give me details on how this could be done?

    Hi,
    have a look at webutil on otn.oracle.com/products/forms ---> Webutil
    Webutil has the capability to load files into the database.
    Frank

  • How to insert data to the specified row column of the multi column list box

    Hi All
    How do i insert data into the specified column of the multi cplumn list box?
    I have a table that containsall station nos and name.Then another table contains the data the various stations having at  for 24 hrs.That is 12 am to 11 pm.
    And i want to display each stations details as follows using a multi column list box/table
    My stationinfo table
    stnno   stnname......................
    s1           stn1
    s2            stn2
    s3             stn3
    The other table
    stnno      sysdatetime       data
    s1             12am                   1
    s2              12am                   4
    s1               1  am                 2
    So the station s1,s2.... will have data for 24 hrs.
    And i want to display it as follows using a multicolumn listbox
    stnname        12am   1 am ......................................11pm
    s1                   ...................
    s2                 ........................
    What i have in my  mind is to get all station nos
    and in a for loop get the station's data from 12 am to 11 pm
    or
    select every statios data for each hor.But in this case i have to query the database 24 times.So i dont think its a good way.
    Or any other better query available?
    Can anybody suggest me a good idea?
    One more thing...how to insert data into the specified field row or column of a multi column list box?
    Thanks in advance

    hi
    i want to know,,can u say ur need clearly...and i attached two image u see that one
    Indrajit
    | [email protected] | [email protected] .
    Attachments:
    station.JPG ‏35 KB
    station2.JPG ‏79 KB

  • How to insert an upper value into a column?

    Hi!,
    I need to insert an upper value into a column.
    The data is on a flat file and it could be lowercase or uppercase?
    Do I have to create a trigger to solve this problem?
    How could the trigger be?
    Thanks,
    Alex

    If you are using SQL*Loader to load the data from flat file into the db table, then you can achieve inserting the UPPER Case of column value in your sqlloader ctl file itself as in below example
    LOAD DATA
    INFILE *
    APPEND INTO TABLE XXX
    ( field1 position(1:7) char "UPPER(:field1)",
    field2 position(8:15) char "UPPER(:field2)"
    BEGINDATA
    Phil Locke
    Jason Durbin
    So in this case the Names Phil Locke and Jason Durbin will be inserted as PHIL LOCKE and JASON DURBIN into the target table.
    Regards,
    Murali Mohan

  • How to Insert check box value into database column

    Hi All,
    I had checkbox group in a region which is using an LOV......and having 18 items in that lov.
    i.e. Total 18 checkboxes in Total. User has to select only 2 checkboxes from that 18.
    I created two columns for storing two values of checkboxes. How to insert two selectives in two columns.........Moreover, How to give the query i.e. how to know which values are selected.
    Please Help me in achieving this. apart from the two columns (Focus1,Focus2) .......One more column(l_spo_val) is there which is a foreign key.
    My Insert Statement is like this:
    INSERT INTO SPO_RESEARCH_FOCUS VALUES(l_spo_val
    ,:P4_RESEARCH_LIST_1
                        ,:P4_RESEARCH_LIST_2);
    Please narrate the code if possible.
    Thanks,
    Sekhar.

    Hi Denes,
    I saw the example in your workspace and it is the same what exactly i want and instead of storing in one column i want to store the two selected values into two different columns. Also i need to restrict the selection of checkboxes upto 2 only. So If the user tries to select the third check box it doesnt have to accept.
    Even I am ready to change my table as according to your example i.e. creating only one column. Store the values of selection into that column.
    I was unable to see how u wrote the logic (Code) for your example in your workspace. It helps alot if you provide me the code for that example(Multi Checkbox One Column).
    I was facinated after watching your examples in your workspace and am very much interested to know more about Apex.
    Please help me insolving this as it is long pending issue for my requirement.
    Thanks a lot again,
    Sekhar.
    Edited by: Sekhar Nooney on Mar 26, 2009 4:35 AM

  • How to insert a value into a field of binary type?

    I've been using Oracle for a while now but never dealt with BLOB
    or long raw type before. Does anyone here know how to insert a
    record into a field of either blob or long raw type?
    Any suggestions would be very appreicated.
    Thanks.

    pls used the loadfromfile procedure which is in the DBMS_LOB
    package to insert the data from external os file into blob data
    type column.
    Kunjan

  • How to schedule a job occurring time for 1 1/2 hour in sql server

    how to schedule a job occurring time for 1 1/2 hour in sql server

    Hi,
    This is a known issue in the previous SQL Server version and has been fixed in SQL Server 2012. You should be able to set 90 minutes and the change would be saved in SQL Server 2012.
    http://connect.microsoft.com/SQLServer/feedback/details/346786/ssms-does-not-support-job-schedule-frequencies-greater-than-60-minutes
    Currently, you may schedule the job to occur every 1 hour or you may refer to the suggestion by Latheesh to get around this.
    Thank you for your understanding.
    Tracy Cai
    TechNet Community Support

  • How to get PDF iFilter to recognize "pdf" document_type instead of ".pdf" in SQL Server 2012

    Hi,
    If this isn't the correct forum for this question, I apologize.
    I am running SQL Server 2012 on a Windows 7 Pro (64-bit) laptop and wish to be able to perform Full-Text searches against the contents of PDF files that have been loaded into my database using a FileTable. I have not been able to get the PDF iFilter v11.0 working whatsoever so I uninstalled it and installed v9.0 of the Adobe PDF iFilter.  I have confirmed that this filtering works on PDF documents I've inserted into a regular table and specified the file_type as '.pdf'.  However, when SQL Server loads the documents into a FileTable, the filter_type is set to 'pdf' (note: the period is not included -- ".pdf").  When I issue the ALTER FULLTEXT INDEX <tablename> START FULL POPULATION, no indexing occurs against the FILETABLE.
    I've examined the Full-Text Search crawl log and there are no errors occurring. Simply messages stating the population is starting and then completed.
    I've searched the forums here and elsewhere and haven't been able to find a work-around for this.
    Is there any way to get the PDF iFilter to recognize the 'pdf' filter_type in addition to the '.pdf' filter_type?
    Any suggestions would be greatly appreciated.
    Thank you,
    Steve

    Hi Steve,
    These links might e helpful:
    https://dotnettim.wordpress.com/2010/12/02/sql-server-full-text-indexing-using-adobe-pdf-i filter-9-sql-server-2008-r2-64bit/
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/69535dbc-c7ef-402d-a347-d3d3e4860 d72/sql-server-2008-64bit-fulltext-indexing-pdf-not-working-cant-find-ifilter?forum=sqldat abaseengine
    Regards,
    Rave

  • How to clear the existing names in USER NAME drop down list in Sql Server Management Studion in Sql Server 2008 R2`.

    Hi,
      We have Sql Server 2008R2 clustered instance running in 2 nodes with Windows 2008R2 SP1 operating system. I would like to know how I could clear the existing  names  in the USER NAME drop down list in the Sql Server Management studio.
    Thanking in you advance,
    Binny Mathew,

    SQL Server Management Studio 2008 delete the file:
    C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
    http://dynamicsgpland.blogspot.in/2012/04/clearing-remembered-default-login-for.html

  • How to load a comma seprated text file which contain address in to sql server table using ssis package

    Hi,
    I want to load a file which is comma separated and contain address .Problem is that address its self comma seprated so how do I differenciate whether comma used for column seprator or it used in address.
    for eg.
    One person having address like
    "c/o AB corp,156 cross lane,USA"
    Thanks.....

    Hi SR_MCTS,
    Based on your description, you want to distinguish a comma is used for column separator or used in address column in a text file, then load the data from the text file to SQL Server table.
    As per my understanding, if you can replace the comma column separator to another delimiter like semicolon (;), just do it. Then we can select Semicolon {;} as Column delimiter for the Flat File Connection Manager. Or ensure all columns are enclosed in double
    quotes ("). Then we can set the double quotes (") as Text qualifier for the Flat File Connection Manager, and the commas will be loaded as part of the string fields.
    If you can't have that done, because computers don't know the context of the data, you would have to come up with some kind of rules that decides when a comma represents a delimiter, and when it is just part of the text. I think a custom script component
    would be necessary to pre-process the data, identify where a comma is part of an address, and then treat that as one field.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • How do I reformat my external hard drive from fat32 to HFS??

    I have an iomega hdd 160gb hard drive and need to move files larger than 4gb to my external hard drive. Hard drive is currently formatted to fat32. How in the world can I reformat this drive to the mac friendly hfs so that I can backup my files?? Any

  • Something's Wrong with my Screen Saver !!!

    For some reason I can't seem to turn off my screen saver. I go to system preferences and swith the "start screen saver" to either "never" or "2 hours", etc and it goes off in like 10-15 minutes anyway. The weird thing is that it doesn't even go into

  • Problem: insert images by script

    Hello. I have problem with insert images from script like this: <& "H:\P1010014.tif">. After insert all images are square :( But i need its own sizes and proportions. P.S.: i can`t write in tag width and height because in all images its different

  • How do I open old mail files held locally within my Thunderbird profile

    I have several old mail files that are in the imap subfolder of my default Thunderbird profile held in Appdata/roaming/thunderbird. The mail accounts are no longer active on the net but I now need to see an old email from several years ago and I can'

  • ISCSI support on Solaris

    A recent article on Search Storage asserts that Solaris 10 will support iSCSI. Is this true or just another journalistic fantasy?