This discussion is archived
0 Replies Latest reply: Jul 22, 2011 4:21 AM by 420476 RSS

OrdDicom and Java

420476 Newbie
Currently Being Moderated

After going through a lot of docs, samples, dead links, manuals and other stuff, i finally managed to write java app which reads and updates objects stored in DICOM column. However, still I am not able to upload an image data into database. Code which separates the issue looks like this:

import oracle.jdbc.*;
import java.sql.*;
import oracle.ord.dicom.OrdDicom;

public class BasicExample3 {

     public OracleConnection connect( ) throws Exception{
          Class.forName ("oracle.jdbc.driver.OracleDriver");
          OracleConnection con = (OracleConnection)DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","SYSTEM","********");
          return con;

     public void runExample() {   
          try {   
               OracleConnection con = connect();
               Statement s = con.createStatement();
               CallableStatement cs = con.prepareCall("{ CALL ordsys.ord_dicom.setDataModel() }");
               OracleResultSet rs = (OracleResultSet)s.executeQuery("Select max(id_zdj) from obrazy");
               int maxId = rs.getInt(1) + 1;
               System.out.println("Inserting empty image...");
               s.executeUpdate("insert into obrazy(id_zdj, dicom) values (" + maxId + ", ORDSYS.ORDDicom())");
               System.out.println("Empty image inserted.");
               rs = (OracleResultSet)s.executeQuery ("select dicom from obrazy where id_zdj = " + maxId + " for update ");
               if( {                
                    OrdDicom image = (OrdDicom)rs.getCustomDatum(1, OrdDicom.getFactory());
                    if(image.isLocal()) {
                         System.out.println("Image is stored locally.");
                    } else {
                         System.out.println("Image is stored externally at " + image.getSourceInformation());
                    if(!image.loadContent(new FileInputStream("C:\\DICOM\\dic1.dcm"), true)) {
                         System.out.println("loadContent failed!");
                    image.setProperties( );
                    OraclePreparedStatement stmt1 = (OraclePreparedStatement)
                    con.prepareCall("update obrazy set dicom = ? where id_zdj = " + maxId);
                    stmt1.execute( );
                    stmt1.close( ) ;
                    System.out.println("Seems to work.");
               } else {
                    System.out.println("Record not found.");
          } catch(Exception e){
     public static void main(String[] args){
          BasicExample3 example = new BasicExample3();


Please do not mind the way ID is generated, in my main application sequence is used for this. Anyway, application output is:

Inserting empty image...
Empty image inserted.
Image is stored externally at ???:/null/null
loadContent failed!

So my question is: what is wrong with approach above? All I need is to insert a record with locally stored DICOM object into database - so maybe I should use different ORDDicom constructor? Maybe creating empty image and uppdating it with data is not a correct approach?

Any help would be greatly appreciated.

Best regards,


  • Correct Answers - 10 points
  • Helpful Answers - 5 points