Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: issue with reading a clob variable from oracle

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default issue with reading a clob variable from oracle

    Here's the deal,

    I created a class named ' Data' with the variables:

     
     
     
    public class Data{
     
        private Clob isRevision;
        private long storeId;
        private long id;
     
        Data(ResultSet rs) throws SQLException {
     
            this.setStoreId(rs.getLong("ID");  
            this.setId(rs.getLong("ID");  
            this.setIsRevision(rs.getClob("IS_REVISION");
        }
     
      // getters and setters
     
      public Clob getIsRevision(){
     
         return isRevision;
      }
     
      public void setIsRevision(Clob isRevision){
     
        this.isRevision = isRevision;
      } 
     
    }

    I also have created a function callled getData() in my DAO class that retrieves the data from an oracle database and stores it to the Data.java class


    I then use a controller class with a function that passes the data to a datastore object using JSON:

     
     
       public JSONObject getData() throws IOException, NamingException, SQLException, JSONException  
        {
          DataService service = DataService.getInstance();
     
          // Get Collection of RmsIndex.
          Collection<DATA> data = service.getData();    
     
          JSONArray items = new JSONArray();
     
          if (id != null)
          {
            JSONObject jo = null;
     
            for (Data p : data) 
            {
              jo = new JSONObject(p, true);
              items.put(jo);
            }
          }
     
          JSONObject dataStore = new JSONObject();
          dataStore.put("identifier", "storeId");
          dataStore.put("label", "Id");
          dataStore.put("items", items);
     
          return dataStore;
        }


    This all works when I read variables that are not Clob type. This only fails when I use the Clob type.

    The errors I receive are:

     
     Java.lang.RuntimeExeption
     Java.lang.reflect.InvocationTargetException
     java.sql.SQLException: Unsupported Feature
     oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java.134)


    I did not mention the service class but if you are familiar with MVC i am sure you know what this is.

    Please Help?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,358
    Thanks
    182
    Thanked 834 Times in 777 Posts
    Blog Entries
    5

    Default Re: issue with reading a clob variable from oracle

    Have you tried to 'hide the Clob' and just rely on its String value? For example, something along the lines of:

    public class Data{
     
        private Clob isRevision;
        private long storeId;
        private long id;
        private String rev = null;
     
    .......
      public String getIsRevision(){
        if ( rev == null ){
            rev = isRevision.getSubString(0, isRevision.length());
        }
         return rev;
      }
     
      public void setIsRevision(String isRevision){
        this.isRevision.truncate(0, this.isRevision.length());
        this.isRevision.setString(0, isRevision);
        rev = null;
      } 
     
     
    }

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: issue with reading a clob variable from oracle

    Is there not a more standard way to do it or someway easier to deal with?

    Thanks

Similar Threads

  1. Executing Oracle Procedure
    By java_mein in forum JDBC & Databases
    Replies: 0
    Last Post: May 14th, 2010, 03:41 PM
  2. jsp and oracle
    By sri latha in forum JDBC & Databases
    Replies: 0
    Last Post: March 10th, 2010, 09:29 AM
  3. Create a CLOB object with the string value
    By oshoarun in forum JDBC & Databases
    Replies: 0
    Last Post: March 6th, 2010, 02:54 AM
  4. Oracle and Sun
    By copeg in forum The Cafe
    Replies: 2
    Last Post: January 31st, 2010, 07:00 AM
  5. Oracle to Buy Sun
    By Fendaril in forum The Cafe
    Replies: 2
    Last Post: June 21st, 2009, 11:48 AM