Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with JDBC BLOB

vishnu.vyasanJul 20 2010 — edited Nov 20 2014
Hi Guys,

i am facing some problem in inserting a image in to oracle database. My program works perfectly in my local environment and fails miserably in the production set up.

Code for image insertion in to db
 try 
    {
      conn = Utilities.getDBConnection();
      log.info("Connection is :"+conn);
      String path = request.getContextPath()+"\temp\test.jpg";
      log.info("The File Path is  :"+path);
      File uploadedFile = new File(path);
      long len = uploadedFile.length();
      log.info("The Length of the File is :"+len);
      
      FileInputStream is = new FileInputStream(uploadedFile);
      
      if(conn!=null)
      {
        ps = conn.prepareStatement(query);
        ps.setString(1,"test.jpg");
        ps.setBinaryStream (2, is, (int) uploadedFile.length());
        count = ps.executeUpdate();
        is.close();
        
      }
      else
      {
        out.println("No Connection");
      }
    }
    catch(SQLException ex)
    {
      log.error("SQL Exception Occoured", ex);
    }
    catch (Exception ex) 
    {
      log.error("Exception Occoured", ex);
    } finally 
    {
      Utilities.closePrepareStatement(ps);
      Utilities.closeJDBCConnection(conn);
    }
Now my local environment :

oc4j jdeveloper: 10.1.2 , db client: 10g , and jdk version: 1.4. oracle thin driver and OS: Windows.

Production :
oracle app server: 10.1.2, hp unix, jdk 1.4.

After spending a week on top of this in the internet forums and various trials and errors still i am to get an answer on this, The error could be because of one of the below listed reasons.

1) Driver issue: i downloaded the latest classes12.jar and ojdbc14.jar in to my webinf lib folder and deployed the application. Somebody suggested in another forum to use orion-web.xml with entry
<web-app-class-loader search-local-classes-first="true" />
this is also not working , and when i tried to add the same for the Global-web-app.xml in config directory. After this my server is not starting up at all and i ahd to remove the entry.

2) the second reason could be because of the change in OS, Windows in my local environment to Unix in my production. Could anyone check and tell me weather i am using any windows specific things in my code.

I am in dire need for help as my applications dead line is fast approaching.

Thanks in Advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2010
Added on Jul 20 2010
5 comments
1,486 views