MySQL Blob insert

I need to insert some .doc files to mySQL Table. so i am using mysql blob data type for this. My Question is now, is there any way to submit the documents to mysql database table with out writing that file to Directory in the WEBROOT.

I tried it with this coding and it gets executed in the local machine successfully. but the problem occurs when i tried to execute the app using another machine in my LAN.
Error is getting then like:
java.io.FileNotFoundException and E:\file_name.docJSP>>>>
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*, java.io.*" errorPage="" %>
<%
                    String my_file = request.getParameter("my_file");
                    FileInputStream fis=new FileInputStream(my_file);
                byte[] b= new byte[fis.available()];
                fis.read(b);
      try{
     String drivername = "org.gjt.mm.mysql.Driver";
     Class.forName(drivername).newInstance();
     String path="jdbc:mysql://localhost/my_db?user=root&password=dba";
     Connection con=DriverManager.getConnection(path);
    PreparedStatement st=con.prepareStatement("insert into docs(d_content) values(?)");
      st.setBytes(1,b);
     int rows=st.executeUpdate();
     if(rows > 0 )
           out.println("Values inserted succesfully");
         else
         out.println("Insertion Failed,Please try Again");
          catch(Exception e1)
          out.println(e1);
%>

Similar Messages

  • BLOB insert behavior with thin driver using standard JDBC2.0 and ORACLE-JDBC2.0API

    We have a problem with a BLOB insert to an oracle 8.1.7 DB using Oracle 8.1.7 JDBC thin driver.We get socket read/write error after inserting 32k of data using the standard JDBC2.0 API but using the Oracle JDBC2.0API (using OracleResultSet) it goes fine. We have a requirement to use the standard JDBC2.0 so that our code works with multiple database vendors. Is there another way to get in the blob data with standard JDBC API & using thin driver...?
    thanks,
    Madhu
    Here is my sample test program that does both standard & oracle specific JDBC Blob test insert.
    import java.sql.*;
    import java.io.*;
    import oracle.sql.BLOB;
    import oracle.jdbc.driver.OracleResultSet;
    public class testBLOB {
    //trying to insert a huge file to a BLOB
    static String fileName = "/kernel/genunix";
    public static void main(String[] args) {
    String driverName = "oracle.jdbc.driver.OracleDriver";
    String dbURL = "jdbc:oracle:thin:@localhost:1521:test"; //thin driver
    String user = "BlobTest";
    String passwd = "BlobTest";
    Connection con=null;
    try {
    Class.forName(driverName);
    con=DriverManager.getConnection(dbURL, user,passwd);
    catch (Exception e) {
    e.printStackTrace();
    close(con);
    int i = 0;
    while (i < args.length) {
    if (args.equals("-f"))
    fileName = args[++i];
    i++;
    System.out.println("The file being Stored is: "+fileName);
    createTable(con);
    insertUsingOracleAPI(con);
    insertUsingJDBC20API(con);
    //readDB(con);
    static String getFileName() {
    return fileName;
    public static void close(Connection con) {
    try {
    if (con != null) {
    con.close();
    catch (Exception e) {
    System.exit(-1);
    public static void createTable(Connection con) {
    Statement stmt ;
    try {
    stmt = con.createStatement();
    stmt.execute("DROP TABLE basic_blob_table");
    stmt.close();
    catch (SQLException sqlEx) {
    System.out.println("Dropped the Table");
    try {
    stmt = con.createStatement();
    stmt.execute("CREATE TABLE basic_blob_table ( x varchar2(30), b blob)");
    stmt.close();
    catch (SQLException sqlEx) {
    sqlEx.printStackTrace();
    close(con);
    System.out.println("Created the Table");
    public static void insertUsingOracleAPI(Connection con) {
    OutputStream os = null;
    Statement stmt = null;
    ResultSet rs = null;
    FileInputStream is = null;
    try {
    con.setAutoCommit(false);
    stmt = con.createStatement();
    stmt.execute("INSERT INTO basic_blob_table VALUES( 'OracleAPI', empty_blob())");
    System.out.println("Inserted the dummy Row");
    rs = stmt.executeQuery("Select * from basic_blob_table where x='OracleAPI'");
    if (rs != null && rs.next()) {
    BLOB blob = ((OracleResultSet)rs).getBLOB(2);
    File file = new File(getFileName());
    is = new FileInputStream(file);
    os = blob.getBinaryOutputStream();
    byte[] chunk = new byte[1024];
    int length = -1;
    while((length = is.read(chunk)) != -1)
    os.write(chunk, 0,length);
    System.out.println("Inserted the File " + getFileName() );
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    if (os != null) {
    os.flush();
    os.close();
    if (is != null)
    is.close();
    stmt.close();
    con.commit();
    con.setAutoCommit(true);
    catch (Exception e) {}
    public static void insertUsingJDBC20API(Connection con) {
    PreparedStatement stmt = null;
    FileInputStream is = null;
    try {
    stmt = con.prepareStatement("INSERT INTO basic_blob_table VALUES(?,?)");
    File file = new File(getFileName());
    is = new FileInputStream(file);
    stmt.setString(1,"JDBC20API");
    stmt.setBinaryStream(2,is,(int)file.length());
    stmt.executeUpdate();
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    if (is != null)
    is.close();
    stmt.close();
    catch (Exception e) {}
    null

    Thanks for the response.
    I understand what you are saying...
    that readers don't block writers in Oracle (the same is true in SQL Server 2000).
    However, I don't see how my test case is working correctly with Oracle (the exact same code acting as I'm thinking it should with SQL Server, but I still think it is acting incorrectly with Oracle).
    I have transaction A do this:
    update <table> set <column2>=<value> where <column1>='1'
    then I use Thread.sleep() to make that program hang around for a few minutes.
    Meanwhile I sneak off and start another program which begins transaction B. I have transaction B do this:
    select * from <table> where <column1>='1'
    and the read works immediately (no blocking... just as you have said) however, transaction A is still sleeping, it has not called commit() or rollback() yet.
    So what if transaction A were to call rollback(), the value read by transaction B would be incorrect wouldn't it ?
    Both A and B use setAutoCommit(false) to start their transactions, and then call setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED).
    Isn't that supposed to guarantee that a reader can only read what is committed ?
    And if a row is in "flux"... in the process of having one or more values changed, then the database cannot say what the value will be ?
    I can almost see what you are saying.
    In letting the reader have what it wants without making it wait, I suppose it could be said that Oracle is holding true to the "only let committed data be read"
    So if that's it, then what if I want the blocking ?
    I want an entire row to be locked until whoever it in the middle of updating, adding, or removing it has finished.
    Do you know if that can be done with Oracle ? And how ?
    Thanks again for helping me.

  • Download File From MySQL BLOB

    I have written code to successfully upload files of all types to a MySQL database BLOB column. Does anyone have any working code that successfully downloads a file from the MySQL database BLOB column and prompts the user with a Save/Open dialog box that does not involve first writing to the filesystem?
    I have used the following which works for Microsoft Word files but does not work for Microsoft PowerPoint files. Any suggestions?
    String extension = methodToReturnExtension(request);
    response.setContentType( "application/octet-stream" );
    String fileName = "FileName" + extension;
    response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
    BufferedInputStream bufferedInputStream = new BufferedInputStream( methodToReturnInputStream() );
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    int start = 0;
    int length = 1024;
    byte[] buff = new byte[length];
    while ( bufferedInputStream.read( buff, start, length ) != -1 )
         byteArrayOutputStream.write( buff, start, length );
    bufferedInputStream.close();
    response.setContentLength( byteArrayOutputStream.size() );
    response.getOutputStream().write( byteArrayOutputStream.toByteArray() );
    response.getOutputStream().flush();For PowerPoint files it tells me that PowerPoint cannot open this file so I am assuming the data is getting corrupted somehow. Any help would be appreciated.
    Thanks,
    Jim

    OK I figured this out...for the most part. The following code works as long as you follow the additional steps listed underneath the code as well.
    //1.  Get the extension and create the filename
    String ext = methodToReturnExtension();
    String fileName = "ConopsDocument" + ext;
    //2.  Set the headers into the request.  "application/octet-stream means that this
    //    is a binary file.
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
    //3.  Write the file to the output stream.
    BufferedInputStream bufferedInputStream = new BufferedInputStream( methodToReturnInputStream() );
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    int data = -1;
    while ( (data = bufferedInputStream.read( )) != -1 )
         byteArrayOutputStream.write( data);
    bufferedInputStream.close();
    response.setContentLength( byteArrayOutputStream.size() );
    response.getOutputStream().write( byteArrayOutputStream.toByteArray() );
    response.getOutputStream().flush();
    response.setHeader("Cache-Control", "no-cache");
    Additional Steps
    1) You must write this file to a MySQL LONGBLOB, a MySQL BLOB column will hold only up to 65 K worth of data, which is much smaller than I would like the users to be able to upload.
    2) You must change the max_allowed_packet parameter of my.cnf (my.ini on windows) to a larger number to avoid a PacketTooBigException. For my purposes I changed it to 50M.
    Additionally, I am restricted by tomcat (I believe it's tomcat) from uploading files greater than about 20 Meg. I am still not sure why but for my purposes around 15 Meg will suffice and I am not going to spend any more time investigating this issue.
    Hope this helps anyone out there looking for info on this subject.

  • BLOB Insertion Problem

    We are inserting a BLOB in our table. If the size of BLOB is greater than 5KB, it's not being inserted. Smaller BLOBs are being entered successfully. Is ther some default parameter which need to be set.

    AFAIK there is no such initialization parameter.
    How do you insert BLOB ? Which is the host language ?
    Which use case described in http://download-uk.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl10pst.htm#125074 is the closest to the one you are using ?

  • Php/MySQL database insert record issue...

    I have a php page that adds an "order" to a mysql database table (orders). One text field in the form is for tires/wheels. The description of the wheels often includes the " symbol for inches after a number....Everything submits fine, however when I look at the page that displays the orders all the data after the " symbol including the " symbol is gone... DOes anyone have any idea why this may be happening? It is requiring us to return and edit that area repeatedly. Any help is appreciated greatly. Thanks for your time.

    Ok, so just to summarize so I am understanding this correctly.  You have an ordering page for tires/wheels.  A customer places an order for tires/wheels and the data is submitted successfully and this includes a symbol for measurement (in.).  But on another summary page the symbol is returning a blank value.
    If this is correct we need to see:
    - First, the code that is inserting the symbol to the database table in question
    - Second, the query and code where you are printing the data to the screen.

  • PHP/MySQL Record Insert question

    I am working with which PHP 4.4.2, MySQL Server 5.0 running
    on Apache 2.0.55, and I am developing my web-site with Dreamweaver
    8. All of which is running locally on my machine.
    I am working on a real-estate website that allows landlords
    around my local area to login to the web-site and add their
    apartment or housing rental units into a database that students
    that go to my small university can browse and search through. The
    landlords register through a form that loads into a 'landlords'
    table in the database and MySQL auto-increments an ID into a
    'landlord_id' column which obviously assigns them their
    'landlord_ID'.
    My question is: When the landlord is filling out the form to
    add one of their rental units ( which loads into a separate table I
    called 'sites'), how can I make their 'landlord_id' (which resides
    in the 'landlords' table) be entered into the 'landlord_id' column
    in the 'sites' table for each site that they enter into the
    database?
    I'm trying to do this because when the landlord first logs
    in, I'm going to have a dynamic table that displays all of the
    sites they already have entered in the database, and only displays
    their sites that they have already entered in by only displaying
    the sites that have their 'landlord_id' in the site record.
    Thanks so much for your help, and if I'm being confusing at
    all, please reply or email me so I can clarify.

    Cade06 wrote:
    > Thanks alot for your reply, but I am completely new to
    MySQL, and I am not
    > quite sure how the syntax works. When you say " WHERE
    landlord_username =
    > 'whatever' "I'm not sure what needs to go in the
    'whatever' portion of the
    > code. Do I need to insert static text here or something
    else? I am totally out
    > of my element here, sorry :-/
    It's probably not so much MySQL syntax that's the problem for
    you, but a
    lack of understanding how to work with Dreamweaver
    recordsets, server
    behaviors, and sessions. Building database-driven sites with
    Dreamweaver
    isn't difficult, but there are a lot of things involved.
    The Log In User server behavior automatically creates a
    session variable
    called $_SESSION['MM_Username']. You can use this as a
    parameter to pass
    to the SQL query in the Advanced Recordset dialog box. In the
    SQL area
    you would type (I'm guessing the name of your table and the
    username
    column):
    SELECT landlord_id FROM landlords
    WHERE landlord_username = 'col1'
    Then click the plus button above the Variables area, and
    create a
    Parameter with the following values:
    Name: col1
    Default value: 1
    Runtime value: $_SESSION['MM_Username']
    You can then extract the result of the recordset, and assign
    it to a
    session variable like this:
    $_SESSION['landlord_id'] = $row_recordsetName['landlord_id'];
    > Also, I understand that I need to do this on the login
    page, but do I need to
    > define the recordset again on the add_site page as well?
    I guess I'm still not
    > quite clear on how I specify the session variable as the
    value that needs to be
    > entered in the sites table as the landlord_ID.
    As long as the session is still valid (which it would be if
    you use
    Restrict Access to Page), you will always have access to that
    landlord's
    id through $_SESSION['landlord_id'].
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • BLOB insertion in Oracle 10g database using ojdbc14 (10g drivers)

    Hello!
    I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
    10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
    <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
    And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
    insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
    following issue fixed in SP3.
    <b>CR124933</b>
    <b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
    the connection was available for reassignment.
    Code was added to ensure the BLOB is completely processed before closing the pool connection or
    ending the transaction.</b>
    I believe the problem arises when we try to insert BLOB into database using a refreshed connection
    from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
    But this still continues to behave intermittently.
    We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
    WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
    ${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
    ${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
    ${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
    export WLS_CLASSPATH
    CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
    export CLASSPATH
    After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
    Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
    to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
    Following is the stack trace of the errors that I recieve:
    <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
    "MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
    java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
    Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
    Please let me know if there is anything that I am missing.
    Thanks
    Pradeep G

    pradeep g wrote:
    Hello!
    I have a situation where I am trying to insert a blob data into oracle 10g database using oracle thin
    10g drivers, <b>ojdbc14.jar</b> in <b>weblogic 8.1 sp2</b>. I have the following error happening very intermittently.
    > <u><b>java.sql.SQLException: OALL8 is in an inconsistent state.</b></u>
    And this is leading to the <u><b>"No more data to read from socket"</b></u> error when I am trying to
    insert the BLOB into the database. I have gone through the bug list of SP2 and have realised there is the
    following issue fixed in SP3.
    > <b>CR124933</b>
    <b>An Oracle BLOB sometimes used a pooled connection after the connection pool determined that
    the connection was available for reassignment.
    Code was added to ensure the BLOB is completely processed before closing the pool connection or
    ending the transaction.</b>
    > I believe the problem arises when we try to insert BLOB into database using a refreshed connection
    from the pool.We have upgraded weblogic 8.1 from SP2 to SP4 service pack inorder to come over the above problem.
    But this still continues to behave intermittently.
    We put ojdbc14.jar in our classpath and Weblogic startup classpath looks like the following :-
    > WLS_CLASSPATH=${WLS_DOMAIN_DIR}/appslib/server.jar:$PRE_CLASSPATH:${WLS_WEBLOGIC_HOME}/server/lib/weblogic.jar:
    ${WLS_WEBLOGIC_HOME}/server/lib/ojdbc14.jar:${WLS_WEBLOGIC_HOME}/server/lib:${WLS_JAVA_HOME}/lib/tools.jar:
    ${WLS_JAVA_HOME}/jre/lib/rt.jar:${WLS_WEBLOGIC_HOME}/server/lib/webservices.jar:${WLS_CONFIG_DIR}:
    ${WLS_CUSTLIB_DIR}:${WLS_BIN_DIR}:$POST_CLASSPATH
    export WLS_CLASSPATH
    CLASSPATH=${WLS_CLASSPATH}:${APP_CLASSPATH}
    export CLASSPATH
    > After upgrade to SP4, there are new ojdbc14_g.jar(debug jar) and orai18n.jar jars in the ${WLS_WEBLOGIC_HOME}/server/ext/jdbc/oracle/10g directory added.
    > Please let me know if I need to update classpath with the new 10g jars in the ext/lib directory or any suggestions
    to insert BLOB using the ojdbc14 10G drivers, Weblogic 8.1 environment would be appreciated.
    > Following is the stack trace of the errors that I recieve:
    > <Oct 6, 2005 1:29:36 PM EDT> <Error> <JDBC> <BEA-001112> <Test "select count(*) from DUAL" set up for pool
    "MHUBPoolStage" failed with exception: "java.sql.SQLException: OALL8 is in an inconsistent state".>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001128> <Connection for pool "MHUBPoolStage" closed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <JDBC> <BEA-001067> <Connection for pool "MHUBPoolStage" refreshed.>
    <Oct 6, 2005 1:29:36 PM EDT> <Info> <EJB> <BEA-010051>
    java.rmi.RemoteException: TransactionRequestManager.requestTransaction():
    Caught PersistnceException com.mortgagehub.busobj.PersistenceException: -5258: No more data to read from socket
    Please let me know if there is anything that I am missing.
    > Thanks
    > Pradeep GHi. This is something we'd like to diagnose. How is your application
    getting using and closing pool connections? The initial symptom
    seems to be an internal oracle problem... Are you using standard
    JDBC or oracle-specific calls?
    Joe

  • BLOB Insert into SQL Server2000

    Dear All,
    I have problem with  insert the BLOB object into MSSQLServer 2000 in WebDynpro.
    Please help me how to solve it?
    Best Regards,
    Mukesh.

    Hi Sweety,
    Can you provide some more information? 
    The script for each of your queries.  (looking especially at how you are using single quotes around the Param properties for different data types)
    Are you using an Command SQL Query for the insert?
    Why are you using the Calculation action block instead of using the Expression Editor for the calculation?
    Regards,
    Mike

  • Oracle BLOB insert problem

    I'm getting a ClassCastException when I try to the blob I get from my CallableStatment. I've seen alot of post about similar issues with oracle 9 and inserting blobs but I havn't found a solution..
    Here is the few lines that Im doing..
    When I check to see what type of instance this blob is this is what I get in my debugger oracle.sql.BLOB@71d768
    so When I ((BLOB)blob).getBinaryOutputStream() I get the ClassCastException..
    I've tried to get the innermost delegate and a number of other things.. When I try to cast anything to the Oracle type I get the ClassCastException. When i do an instanceof on the blob it isn't an oracle Blob.. So why does the debugger and getClass().getName() tell me it is.. And is the any work around for this..
    Thanks
    Dan
    cstmt.registerOutParameter(6, OracleTypes.BLOB);
                 cstmt.execute();
                 Blob blob = cstmt.getBlob(6);
                           if(blob != null) {
                         writer = new ObjectOutputStream( ((BLOB)blob).getBinaryOutputStream());
                        if (writer != null) {
                        writer.writeObject(bean);
                          writer.flush();
                          writer.close();
                     con.commit();

    Yes, I modified some code that a collegue used in a standalone application.. His solution was using a CLOB.. I just modified my solution to use a CLOB instead of a BLOB(saving a bean as xml instead of the bean object)..
    So i litterally copied his code line for line.. And Im getting the same error. My app is running in tomcat whereas my collegue is using it in a standalon application. I just went thru all lib directories to make sure I only have one copy of the oracle ojdbc14.jar which is in the conf/lib directory of the tomcat server..
    I even moved my table from our oracle9 db to our oracle 10 db and still no luck..
    String beanToXml = xstream.toXML(bean);          
    cstmt.execute();
    oracle.sql.CLOB clob = ((OracleCallableStatement) cstmt).getCLOB(6)
                 if (clob != null) {
                     writer = ((CLOB) clob).getCharacterOutputStream();
                     if (writer != null) {
                       writer.write(beanToXml.toCharArray());
                       writer.flush();
                       writer.close();
                 }

  • MySQL - ADF (insert, update)

    I configured well the conection to a MySQL database (latest jdbc driver 5.1.5).
    My connection url is jdbc:mysql://localhost/<databasename>?&ultraDevHack=true&capitalizeTypeNames=true&pedantic=true&sqlmode=oracle
    I can do select,update,insert, delete from Jdev (ver. 10.1.2) SQL Worksheet with no errors.
    I made a simple ADF application (1am,1 ejb,1vo) and run the test appmodule. Primary key is set properly. Select works, but for any kind of update,insert operation I receive
    (java.sql.SQLException) Unable to retrieve metadata for procedure.
    How can I resolve this? Thanks.
    This is the track trace exception:
    java.sql.SQLException: Unable to retrieve metadata for procedure.
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
         at com.mysql.jdbc.CallableStatement.extractProcedureName(CallableStatement.java:967)
         at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:798)
         at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:612)
         at com.mysql.jdbc.CallableStatement.getInstance(CallableStatement.java:510)
         at com.mysql.jdbc.ConnectionImpl.parseCallableStatement(ConnectionImpl.java:3856)
         at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:3927)
         at com.mysql.jdbc.ConnectionImpl.prepareCall(ConnectionImpl.java:3901)
         at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3279)
         at oracle.jbo.server.DBTransactionImpl2.createCallableStatement(DBTransactionImpl2.java:414)
         at oracle.jbo.server.BaseSQLBuilderImpl.doEntityDML(BaseSQLBuilderImpl.java:243)
         at oracle.jbo.server.EntityImpl.doDML(EntityImpl.java:5296)

    I debuged the DML flow and concluded that is a wrong way of ADF to use callable statement despite preparecall statement for UPDATE and INSERT operations, case third party jdbc driver.
    Bellow are some fragments from oracle.jbo.server.BaseSQLBuilderImpl and oracle.jbo.server.DBTransactionImpl which show how ADF manage the DML operations:
    oracle.jbo.server.BaseSQLBuilderImpl.doEntityDML
                DBTransactionImpl dbtransactionimpl = entityimpl.getDBTransactionImpl();
                boolean flag1 = dbtransactionimpl.getLockingMode() == 3;
                callablestatement = dbtransactionimpl.createCallableStatement(stringbuffer.toString(), 1);
                entityimpl.bindDMLStatement(i, callablestatement, entitydefimpl.getAttributeDefImpls(), aattributedefimpl, aattributedefimpl1, hashmap, flag);
                int j = callablestatement.executeUpdate();
    oracle.jbo.server.DBTransactionImpl
        public CallableStatement createCallableStatement(String s, int i)
            int j = 0;
            if(InstrumentedEvent.isActive)
                j = InstrumentedEvent.startEvent(EventGroup.JDBC_CREATE_STATEMENT, "createCallableStatement - prefetch size: " + i);
            CallableStatement callablestatement = null;
            try
                callablestatement = mjdbcConnection.prepareCall(s);
                if(JDBCInteract.mDoTrace)
                    JDBCInteract.prepareCall(s);
                if(i != -1)
                    mSQLBuilder.doStatementSetRowPrefetch(callablestatement, i);
            catch(SQLException sqlexception)
                try
                    if(callablestatement != null)
                        callablestatement.close();
                        if(JDBCInteract.mDoTrace)
                            JDBCInteract.closeStmt(callablestatement);
                catch(SQLException sqlexception1) { }
                if(Diagnostic.isOn())
                    Diagnostic.println("DBTransactionImpl.createCallableStatement failed...");
                    Diagnostic.printStackTrace(sqlexception);
                throw new SQLStmtException(class$oracle$jbo$CSMessageBundle != null ? class$oracle$jbo$CSMessageBundle : (class$oracle$jbo$CSMessageBundle = _mthclass$("oracle.jbo.CSMessageBundle")), "27123", s, sqlexception);
            if(InstrumentedEvent.isActive)
                InstrumentedEvent.endEvent(j);
            return callablestatement;
    ...where mjdbcConnection is instance of java.sql.Connection
    MySql driver fails when it tries to call UPDATE or INSERT as a stored procedure because ADF send the command to do a callable statement, but there is no UPDATE/INSERT procedure/function.
    The driver parameter ultraDevHack is not used (jdbc mysql v. 5.1.5). I traced the code and I never saw the use of ultraDevHack.
    The ADF must use prepare statement for UPDATE/INSERT and not callable statement.
    So, what is the practical solution?

  • PHP/MySQL-Update/Insert Record JavaScript Won't Work!!!

    Hi. I'm consistently running into the following error when I use the update or insert record script in CS4. I've tried deleting the FileCache file. I've tried quitting and relaunching, etc. Anyone else seeing this happen? Solutions anyone? Thanks in advance...
    I'm beginning to think it has something to do with the database, and not the script. Does anything in the screenshot below look wrong or problematic?
    Okay, I found the problem. Shouldn't be a problem, but it is...
    The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.

    airsoftie wrote:
    Okay, I found the problem. Shouldn't be a problem, but it is...
    The Field name "length" changed to "height" eliminated the problem. So, you can't use the word "length" in a field? Sounds weird to me.
    There are lots of words you can't use for column names in MySQL, but "length" isn't one of them. See http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html.
    The problem arises because Dreamweaver uses JavaScript behind the scenes to populate dialog boxes and build server behaviors. In JavaScript, "length" is the property of an array. I suspect the problem is that using "length" as a column name has given the relevant JavaScript used by Dreamweaver indigestion.

  • Help for ADF data binding with MySQL BLOB type.

    Hi,
    I have a blob column called photo for table person in my MySQL database, with ADF, I want to bind this column with a JUImage control, but when I drag the column attribute from the data control palete as a JUImage, an error dialog appears, it says:
    Control cannot be bound to that Attribute.
    This control should be bound to an Attribute whose Java type is one of the following
    oracle.ord.im.OrdImageDomain
    oracle.jbo.domain.BlobDomain
    oracle.jbo.domain.Raw
    What should I do ?
    Thanks.

    Hi,
    Are you using BC4J as the persistence layer? If you use your own persistence (e.g. a bean) then you need to make sure the datatype of the atribute is defined as one of the three mentioned in your question.
    Frank

  • Oracle BLOB insertion

    I am getting a runtime NoClassDefFound error while I am trying to get a handle on the BLOB field (after the insertion of an EMPTY_BLOB()).
    The sequence of events (using Java code) are:
    1. Insert data for the table along with Empty_Blob() for the particular Blob field
    2. Select * from table
    3. Assign a (OracleResultSet)ResultSet.getBLOB()
    At step 3 where the casting occurs, the runtime error is ORACLE_HOME/jdbc/driver/OracleResultSet()
    NoClassDefFound
    null

    I tried inserting using the following code and it worked in single stepOnly if your Data is not longer then 4000 Bytes (or 32K if you do the same in PL/SQL). Otherwise you have to use empty_blob.
    Dim

  • We are trying to display MYSQL Blob field

    We found a code to get the image to show up but we don't
    understand what
    $_get means.
    any help would be appreciated
    Steve Warburton
    0161 217 2200
    07760 164990
    [email protected]

    On 10 Jun 2008 in macromedia.dreamweaver, SteveW wrote:
    > We found a code to get the image to show up but we don't
    understand
    > what $_get means.
    http://www.php.net/manual/en/reserved.variables.get.php
    > any help would be appreciated
    Some context would help...
    Joe Makowiec
    http://makowiec.net/
    Email:
    http://makowiec.net/contact.php

  • How to handle blob data with java and mysql and hibernate

    Dear all,
    I am using java 1.6 and mysql 5.5 and hibernate 3.0 . Some time i use blob data type . Earlier my project's data base was oracle 10g but now i am converting it to Mysql and now i am facing problem to save and fetch blob data to mysql database . Can anybody give me the source code for blob handling with java+Mysql+Hibernate
    now my code is :--
    ==================================================
    *.hbm.xml :--
    <property name="image" column="IMAGE" type="com.shrisure.server.usertype.BinaryBlobType" insert="true" update="true" lazy="false"/>
    ===================================================
    *.java :--
    package com.shrisure.server.usertype;
    import java.io.OutputStream;
    import java.io.Serializable;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Types;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import oracle.sql.BLOB;
    import org.hibernate.HibernateException;
    import org.hibernate.usertype.UserType;
    import org.jboss.resource.adapter.jdbc.WrappedConnection;
    import com.google.gwt.user.client.rpc.IsSerializable;
    public class BinaryBlobType implements UserType, java.io.Serializable, IsSerializable {
    private static final long serialVersionUID = 1111222233331231L;
    public int[] sqlTypes() {
    return new int[] { Types.BLOB };
    public Class returnedClass() {
    return byte[].class;
    public boolean equals(Object x, Object y) {
    return (x == y) || (x != null && y != null && java.util.Arrays.equals((byte[]) x, (byte[]) y));
    public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
    BLOB tempBlob = null;
    WrappedConnection wc = null;
    try {
    if (value != null) {
    Connection oracleConnection = st.getConnection();
    if (oracleConnection instanceof oracle.jdbc.driver.OracleConnection) {
    tempBlob = BLOB.createTemporary(oracleConnection, true, BLOB.DURATION_SESSION);
    if (oracleConnection instanceof org.jboss.resource.adapter.jdbc.WrappedConnection) {
    InitialContext ctx = new InitialContext();
    DataSource dataSource = (DataSource) ctx.lookup("java:/DefaultDS");
    Connection dsConn = dataSource.getConnection();
    wc = (WrappedConnection) dsConn;
    // with getUnderlying connection method , cast it to Oracle
    // Connection
    oracleConnection = wc.getUnderlyingConnection();
    tempBlob = BLOB.createTemporary(oracleConnection, true, BLOB.DURATION_SESSION);
    tempBlob.open(BLOB.MODE_READWRITE);
    OutputStream tempBlobWriter = tempBlob.getBinaryOutputStream();// setBinaryStream(1);
    tempBlobWriter.write((byte[]) value);
    tempBlobWriter.flush();
    tempBlobWriter.close();
    tempBlob.close();
    st.setBlob(index, tempBlob);
    } else {
    st.setBlob(index, BLOB.empty_lob());
    } catch (Exception exp) {
    if (tempBlob != null) {
    tempBlob.freeTemporary();
    exp.printStackTrace();
    st.setBlob(index, BLOB.empty_lob());
    // throw new RuntimeException();
    } finally {
    if (wc != null) {
    wc.close();
    public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
    final Blob blob = rs.getBlob(names[0]);
    return blob != null ? blob.getBytes(1, (int) blob.length()) : null;
    public Object deepCopy(Object value) {
    if (value == null)
    return null;
    byte[] bytes = (byte[]) value;
    byte[] result = new byte[bytes.length];
    System.arraycopy(bytes, 0, result, 0, bytes.length);
    return result;
    public boolean isMutable() {
    return true;
    public Object assemble(Serializable arg0, Object arg1) throws HibernateException {
    return assemble(arg0, arg1);
    public Serializable disassemble(Object arg0) throws HibernateException {
    return disassemble(arg0);
    public int hashCode(Object arg0) throws HibernateException {
    return hashCode();
    public Object replace(Object arg0, Object arg1, Object arg2) throws HibernateException {
    return replace(arg0, arg1, arg2);
    =================================================================
    can anyone give me the source code for this BinaryBlobType.java according to mysql blob handling ..

    Moderator action: crosspost deleted.

Maybe you are looking for

  • How to get the values from the resultset???

    I have a problem with this code given below, i am executing an sql query which return a union of values from two tables. the problem here is how do i read the values from the resultset. here is the code.... package com.webserver; import java.sql.*; p

  • Is there a way to remove my credit card from my apple id

    i need to remove my credit card ftrom my apple id so i can download free apps and there is not a none button

  • Issue in HR

    hi friends - i have an issue in transaction PTMW. i have two fields like start time & end time both type PTM_TDE_N1-beguz & PTM_TDE_N1-enduz respectively (Time - 6char). and i have the difference between these two fields as PTM_TDE_N1-tdduration (Dec

  • Java Problems with web access/Oracle

    I have a new problem I'm wondering if anyone has encountered. I use my G5 PPC to make input into a Government data base. It's been working for a couple of months (since I took on the assignment) but all of a sudden they started to make little 'fixes'

  • FW400 not listed in System-Profiler

    How can i update the Port, that i can connect my Projekt-Mix.