Db2 v8 and jdbc2 driver and Blob

Two questions:
1; I am running ibm db2 v8.1 Universal database.
What jdbc i shipped with that on, is it jdbc2 or jdbc1, i cant find any usejdbc2 file, that you hade to run in version 7.
Is the jdbc enabled at the start of the database?
2; Do i have to use a prepareStatement to insert a Blob to the database?
Best regards,
Anders

1. The db2 version 8.0 doesn't work with jdbc1. it is already shipped with jdbc2.
so u don't have to run any batches as u had to do in db2 version 7.x
2. I tried inserting a BLOB object into the database using JDBC without prepardstatement, but i faild. Trying with prepareStatement, it worked successfully.

Similar Messages

  • Java and BLOB

    Help...
    I need samples for storing files into BLOB by using Java code.
    Anyone knows?

    Here is my full code:
    /* This program is for testing Java and BLOB function */
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    public class BlobApplication {
    static Connection con=null;
    // static Statement stmt,stmt1,stmt2,stmt3=null;
    // static ResultSet rs,rs1,rs2,rs3=null;
    // static OracleConnection con=null;
    static OracleStatement stmt,stmt1,stmt2,stmt3=null;
    static OracleResultSet rs,rs1,rs2,rs3=null;
    static String sqlStr,sqlStr1,sqlStr2,sqlStr3="";
    static long blobLength;
         public static void main(String args[]) {
              try{     
                   Class.forName
    ("oracle.jdbc.driver.OracleDriver");
                   //con=(OracleConnection)
    DriverManager.getConnection
    ("jdbc:oracle:thin:@172.18.41.8:1521","EDB","edb");      
                   con=(OracleConnection)
    DriverManager.getConnection
    ("jdbc:oracle:oci8:@t18new","EDB","edb");      
                   //con=DriverManager.getConnection
    ("jdbc:oracle:oci8:@t18new","EDB","edb");      
                   BlobApplication lobApp=new
    BlobApplication();
                   lobApp.insertIntoLobTable("bfile1.dat");
                   //lobApp.insertIntoLobTable
    ("bfile2.dat");
                   //lobApp.insertIntoLobTable
    ("bfile3.dat");
                   lobApp.saveBlobTableToDisk();
                   con.close();     
              } catch (Exception e) {
                   e.printStackTrace();
         void insertIntoLobTable(String blobFilename){
              try {
         stmt=(OracleStatement)con.createStatement
         //stmt=con.createStatement();     
              stmt.execute("insert into lobtable
    (blobfilename,blobdata) values ('"+blobFilename+"', EMPTY_BLOB
              insertBLOB(blobFilename);
    stmt.close();
              catch (SQLException ex) {
                   System.err.println("Could not insert
    into the table lobtable \n"+ex);
                   System.exit(1);
         void insertBLOB(String filename) throws SQLException {
              try {
                   BLOB aBLOB=null;     
                   System.out.println(filename);     
                   File aFile=new File(filename);
                   FileInputStream aFileInputStream=new
    FileInputStream(aFile);               
         stmt1=(OracleStatement)con.createStatement();
         //stmt1=con.createStatement();     
              //sqlStr1="select * from lobtable where
    blobfilename='"+ filename +"' for update";
                   System.out.println("before query");
              rs1=(OracleResultSet)stmt1.executeQuery
    ("select * from lobtable where blobfilename='"+ filename +"' for
    update");               
              //rs1=stmt1.executeQuery(sqlStr1);          
              //stmt1.executeQuery(sqlStr1);
                   System.out.println("after query");
                   while (rs1.next()) {
                   System.out.println("in the loop");
              aBLOB=rs1.getBLOB(2);               
                             //int
    chunkSize=rs1.getBLOB("blobdata").getChunkSize();
                             int
    chunkSize=aBLOB.getChunkSize();
                             byte[] buffer=new byte
    [chunkSize];
                             int lenRead;
                             long offset=1;
                             while
    ((lenRead=aFileInputStream.read(buffer)) != -1) {
                                  if (blobLength<
    offset) buffer=new byte[lenRead];
                                  //rs1.getBLOB
    ("blobdata").putBytes(offset,buffer);
                                  aBLOB.putBytes
    (offset,buffer);
                                  offset+=lenRead;
              rs1.close();
    stmt1.close();                    
                        aFileInputStream.close();
              catch(IOException e) {
                   System.err.println("Error in
    reading "+filename+"\n"+e);
                   System.exit(1);
         void saveBlobTableToDisk() {
              try {
         stmt2=(OracleStatement)
    con.createStatement();     
         //stmt2=con.createStatement();     
              sqlStr2="SELECT blobfilename,blobdata
    FROM LOBTABLE";
              rs2=(OracleResultSet)stmt2.executeQuery
    (sqlStr2);
              //rs2=stmt2.executeQuery(sqlStr2);
                   while (rs2.next()) {     
                        writeBlobToDisk(rs2.getString
    ("blobfilename"), rs2.getBLOB("blobdata"));
              rs2.close();
    stmt2.close();                    
              catch (SQLException ex) {
                   System.err.println("Could not save to
    disk \n"+ex);
                   System.exit(1);
         void writeBlobToDisk(String filename,BLOB readBlob)
    throws SQLException {
              try {
                   File aFile=new File("blob_"+filename);
                   FileOutputStream aFileOutputStream=new
    FileOutputStream(aFile);
                   int chunkSize=readBlob.getChunkSize();
                   byte[] buffer=new byte[chunkSize];
                   blobLength=readBlob.length();
                   for (long pos=1; pos<blobLength;
    pos+=chunkSize) {
                        chunkSize=readBlob.getBytes
    (pos,chunkSize,buffer);
                        aFileOutputStream.write
    (buffer,0,chunkSize);
                   aFileOutputStream.close();
              catch (IOException e) {
                   System.err.println("Error in
    writing "+filename+"\n"+e);
                   System.exit(1);
    } // End of BLobApplication
    -----------------------------------------------------------------

  • Out of Order Primary Keys and Blob fields

    Hi,
    I am using Oracle Migration Workbench to transfer the data from SQLServer 2000 to ORacle 9i. I am running into the following issues and was wondering if you had any ideas what may be going on:
    1.) Primary keys are out of order
    2.) Blob fields are inserted into the incorrect row
    Ex. BLOB field stating 'Application active' should be associated with Act_key (primary key) = 5 and it ends up transfering over with act_key 28.
    Thank you for any information you may have on this.
    AK

    I am very interested in this thread because I have encountered a similar problem with BLOB columns, except that I am also seeing this with CLOB's.
    Essentially the all the data gets 'migrated', but the CLOB and BLOB columns are all mixed up!
    Any solutions?

  • How we handle CLOB and BLOB Datatypes in HANA DB

    Dear HANA Gurus,
    We have would like to build EDW using HANA base on our source system Oracle and it's supports CLOB and BLOB datatypes
    Would you please suggest how do we handle in HANA DB.
    Let not say it's oracle specific.
    Regards,
    Manoj

    Hello,
    check SAP HANA SQL Reference Guide for list of data types:
    (page 14 - Classification of Data Types)
    https://service.sap.com/~sapidb/011000358700000604922011
    For this purpose might be useful following data types:
    Large Object (LOB) Types
    LOB (large objects) data types, CLOB, NCLOB and BLOB, are used to store a large amount of data such as text documents and images. The maximum size of an LOB is 2 GB.
    BLOB
    The BLOB data type is used to store large binary data.
    CLOB
    The CLOB data type is used to store large ASCII character data.
    NCLOB
    The NCLOB data type is used to store a large Unicode character object.
    Tomas

  • Dbms_crypto and blob datatypes

    Hi everyone
    I've been trying to learn how to encrypt data (a file uploaded) using blob datatype. This is me first attempt at encrypting and have been doing some research on this. I need to use the BLOB as I am encrypting a file that is uploaded to the system. Does anyone have experience in this or know of a good example that I can take a look at?
    Ray

    Hello,
    check SAP HANA SQL Reference Guide for list of data types:
    (page 14 - Classification of Data Types)
    https://service.sap.com/~sapidb/011000358700000604922011
    For this purpose might be useful following data types:
    Large Object (LOB) Types
    LOB (large objects) data types, CLOB, NCLOB and BLOB, are used to store a large amount of data such as text documents and images. The maximum size of an LOB is 2 GB.
    BLOB
    The BLOB data type is used to store large binary data.
    CLOB
    The CLOB data type is used to store large ASCII character data.
    NCLOB
    The NCLOB data type is used to store a large Unicode character object.
    Tomas

  • Db2 sid and sid adm passwords lost

    Hello,
    We are using DB2 on AIX and we have lost passwords for users db2<sid> and <sid>adm.
    Is there any way to recover this passwords?
    Thanks in advance

    Hello
    How about resetting the password?
    Please refer SAP note 582875 and
    Link: http://help.sap.com/saphelp_nw70ehp1/helpdata/en/aa/1dc8d8f0fa11d3a6510000e835363f/content.htm
    Thanks and Best regards
    koju

  • DB2/dbcdb6up and OS users?

    Hello,
        Our shop is running NW 7.0 EnhPack1 BI system on DB2 9.5 FP3 on AIX.  This is our first "live" DB2 system and up till now, we have been an Oracle only shop. 
    I have a quick question about the OS users for the DB2 system.  It seems to me that the OS level users passwords should never change or expire or the SAP system will lose connectivity to the database.  Can anyone tell me if that is definitely the case?
    Looking at note 582875 it seems to confirm this but I can find no SAP documentation that states this implicitly.
    Thanks in advance!!!!
    Don

    Hello Donald,
    It is possible to change passwords of db2<sid>, <sid>adm and sap<sid>.
    For <sid>adm and sap<sid> it is not sufficient to change these passwords on OS level only. They are also stored in encrypted form in a file called dscdb6.conf .
    Changing these passwords should be done via an executable called "dscdb6up" (part of the SAP Kernel). this ensures that also the passwords stored in dscdb6.conf are updated.
    This is described in the [Admin guide|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f03d5fb8-b619-2b10-c383-c6d56872829e] on page 27ff.
    Hope this hepls,
    Regards, Hans-Juergen

  • DB2 iSeries and zSeries

    This post is mostly for the development team. I've seen posts where DB2 iSeries and zSeries will be supported in a future release. Can someone confirm which version (I assume it is not scheduled for release 3)? If it is not schedule, I would be happy to add a feature request in the Developer's Exchange.
    thanks -
    ket

    We can't confirm which release the support will be added in, as the priorities for features in releases can change. I can confirm that we will not support the iSeries and zSeries in SQL Developer 3.0.
    Please do continue to vote in this in the Exchange.
    Regards
    Sue

  • Weblogic 9.2 Oracle Thin Driver and BLOB/CLoB ClassCastExceptions

    Hi,
    I think I may be about to ask a question that has been asked many times but I'm just trying to find the definitive best approach, if any to solve this problem.
    I'm working with Weblogic 9.2 on Windows. I have a couple of JDBC Oracle DataSources configured for container connection pooling and the driver that I'm using is the "Oracle's Driver (Thin) Versions 9.0.1,9.2.0,10". When retrieving a Blob from the DB we're calling
    oracle.sql.BLOB.blob = (oracle.sql.BLOB)(rs.getBlob(..))
    This results in a java.lang.ClassCastException: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB
    The same also occurs for Clobs.
    I found a link to an article written in 2003 (http://forums.bea.com/bea/message.jspa?messageID=200019959&tstart=0) that suggests writing your own OracleConnection wrapper class.
    I'm just wondering does anybody know if BEA have done anything to fix this problem, we're now on Weblogic 9.2 and this issue is still occuring. I'd rather not go down the route of writing additional code just so we can tell our customers that they can run on Weblogic (when they can successfully already run on Websphere and Tomcat).
    Thanks,
    Aoife

    For anyone who was wondering I managed to get this working though I do unfortunatley have to place a weblogic specific class in to my code :-(
    Used information provided at: http://support.bea.com/application_content/product_portlets/support_patterns/wls/CLOBBLOBDataTypeHandlingIssuesPattern.html#Recommended_programming_techniques
    Regards,
    Aoife

  • MySQL and Blobs

    Hey everyone,
    Small question:
    How can I get a string from a Blob (org.gjt.mm.mysql.jdbc2.Blob)? I tried this:
    Blob b = ...;
    String str = new String(b.getBytes(0, (int)b.length()));but that gave me an ArrayIndexOutOfBoundsException. How can I do it?
    Thanks on advance,
    Nille

    That was a confused 'mmm', that a 'you suck' 'mmm'. That would be more like 'hmm' or perhaps 'grmpf'.
    I really appreciate your help, and I'm sorry if I wasn't clear about this.
    Anyway, the new driver solved it. The implementation was poor.
    Nille

  • Oracle ODBC and BLOB in html

    Hi,
    I would like to ask you if cad I use Oracle-ODBC driver (whuch version) for reading BLOB (LRAW) column in html(asp) - JavaScript.
    create table JPG
    CLZM NUMBER(6) not null,
    JPG_FILE LONG RAW null ,
    <% @ LANGUAGE=JavaScript%>
    <%
    Response.Buffer = true;
    Response.ContentType = "image/jpeg";
    Response.AddHeader("Content-Disposition","attachment; filename=test.jpg");
    Response.CacheControl = "public";
    Response.Expires = 0;
    oConn = Server.CreateObject("ADODB.Connection");
    oConn.Open("DSN=ORACLE;UID=scott;PWD=tiger;");
    // Query SQL to obtain recordset containing gif BLOB
    oRs = oConn.Execute("SELECT JPG_FILE FROM JPG WHERE CLZM='3156'");
    // Obtain local variable of /*
    PicSize = oRs("JPG_FILE").ActualSize;
    Pic = oRs("JPG_FILE").GetChunk(PicSize);
    // ??? Obtain only 4 bytey - why ???
    Response.BinaryWrite(Pic);
    Response.End();
    %>
    Thank's
    Ondrej

    I had the same problem using VBScript.
    What you have to do isread in blocks of let's say 1k in a loop and check wether the return value is exactly 1k, if not you may end your loop.
    Here's my code in VBScript.
    Dim varBlob
    Dim varChunk
    Const chuckSize = 1024
    Do
    varChunk = objRs.Fields("blobField").getChunk(chuckSize)
    varBlob = varBlob & varChunk
    Loop While (len(varChunk) = chuckSize)
    the contents of varBlob is your Picture
    null

  • Were to find db2 drivers and how to check if it is working

    i have to configure a scenario from db2 to xi to rfc
    let me know were to find the db2 driver and once done how do i check if i have installed the correct driver. is there any sample program through which i can check if the driver is installed

    Hi Amit,
    IF you have already instaled DB2 databse, then you can get the driver, in this location from your DB2 database folder,
    /usr/local/java/db2/lib/db2jdbc.zip
    If you need to install DB2, then I would suggest that you try this link,
    http://www.ibm.com/software/data/db2/
    http://www-128.ibm.com/developerworks/db2/library/techarticle/0203zikopoulos/0203zikopoulos.html
    As DB2 is a Database from IBM, a search in the IBM website can also help you if the above links do not help.
    Regards,
    Bhavesh

  • JDBC and BLOB

    Hi.
    How can I tune oracle jdbc when inserting blob
    Thanks

    It depends on which driver and which version you are using. Generally it is faster to send data using the direct binds APIs such as PreparedStatement.setBytes or PreparedStatement.setString than using the LOB apis.
    Regards,
    Jean

  • Urgent.Please Help me. DB2 Connectivity and Swings

    Hi.
    I use Jbuilder 7.0 and I want to query from a DB2 database.
    I have used some swing classes in my frame.
    I have defined a new library that contain DB2 JDBC Driver and added it to required Library of my project.
    I have used a DataBase class instance for connecting to DB2.
    in jbuilder designer,after selecting connection property of Database class,I want to select DB2 JDBC Driver from Drivers List.
    In the JDBC Drivers List,I see COM.ibm.db2.net.DB2Driver(DB2 JDBC Driver),but it's color is red and seems that the driver is not accessible.
    Do you know why it's inaccessible?
    any Idea?
    Best Regards.

    Hi all
    Help me please,urgently.
    Thanks.

  • DB2, CDH and adapters: Howto ?

    Hi all,
    First of all, i'm looking for some documentation about how to make CDH manage DB2 (mainframe) tables. By now, l found that an adapter must be configured on Customer Online app, so how can i configure a DB2 adapter (can be other adapter) under Customer Online ? Thank you for your help, regards,
    ED

    Hi Sigi,
    This error is encountered when you have given the wrong connection parameters in your jdbc communication channel.
    Check whether the JDBC Driver and the Connection parameters are correct.Once that is correct, your problem will be solved.
    Regards
    Sunita

Maybe you are looking for

  • Multiple timbres for the same instrument?

    I am writing a peice for three cellos which involves some unisons, and cannot find a way to make the parts sound different for them, resulting in what sounds like one cellist playing the same part three times and layering them. What I have been looki

  • 10g installation key problem

    I am trying to install the 10g developer edition. During the installation process, I am required to register. I go to the registration page, log in, verify the information and click continue. I then get a page with the following information: Informat

  • Do I have Shockwave player?

    Ok stupid question, but Do I have Shockwave player? I don't ever recall installing it nor do I want it but some odd things make me wonder if I have it If I do, then I haven't updated it and that concerns me. When I look in these location, I do not fi

  • JTable- Selection Color

    Hallo, I want to change my border Color of selected Cell. Because I don�t find any possibilty to change this Color. I create my Table with my own AbstractTableModel. Till now, I don�t have write my own TableCellRenderer. Can you help me? Stefan Gabel

  • After upgrade to 12.1.3, ICM is not started successfully

    Hi experts, After upgrade to 12.1.3, a weird problem related to Internal Concurrent Manager(ICM) occurred and i can't fix it by searching this forum. Normally when i start EBS apps tier, i use script adcmctl.sh to start ICM and it exits with status 0