issue with reading a clob variable from oracle
Here's the deal,
I created a class named ' Data' with the variables:
Code :
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:
Code :
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:
Code :
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?
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:
Code java:
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;
}
}
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