4 Replies - 1955 Views - Last Post: 16 July 2012 - 06:15 AM

#1 Metal Wing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 04-March 12

Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

Posted 12 July 2012 - 11:25 AM

I really gave it an honest try for 3 days now. At this point, I have a TaskListTopComponent (Window), and an entity class called Todo.java. In Todo entity class I have a column TDDETAILS that is a MEMO field in a DBF (FoxPro 2.6). I am attempting to get data from it using the following code:

    @Lob
    @Column(name = "TDDETAILS")
    private String details;

    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }


If I remove the code above, my application works perfect and all other 10+ columns can be retrieved, modified, added and deleted.

However, I need the TDDETAILS field and I get the following errors when I use the code above:

Internal Exception: java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Feature is not available.
    Error Code: 0
    Call: SELECT TDTDKEY, TDBILLABLE, TDEMAILED, TDFLATRATE, TDADD_DATE, TDADD_TERM, TDADD_TIME, TDADD_USER, TDCHG_DATE, TDCHG_NUMB, TDCHG_TERM, TDCHG_TIME, TDCHG_USER, TDDETAILS, TDDATEDONE, TDFOLLOWUP, TDINTERNAL, TDPRIVATE, TDREQUIRED, TDSRED, TDTAKEN, TDDESCRIP, TDPRIORITY, TDCMKEY, TDCNKEY, TDJTKEY, TDPYKEY, TDURKEYAS, TDURKEYTB FROM TODO
    Query: ReadAllQuery(name="Todo.findAll" referenceClass=Todo sql="SELECT TDTDKEY, TDBILLABLE, TDEMAILED, TDFLATRATE, TDADD_DATE, TDADD_TERM, TDADD_TIME, TDADD_USER, TDCHG_DATE, TDCHG_NUMB, TDCHG_TERM, TDCHG_TIME, TDCHG_USER, TDDETAILS, TDDATEDONE, TDFOLLOWUP, TDINTERNAL, TDPRIVATE, TDREQUIRED, TDSRED, TDTAKEN, TDDESCRIP, TDPRIORITY, TDCMKEY, TDCNKEY, TDJTKEY, TDPYKEY, TDURKEYAS, TDURKEYTB FROM TODO")



My persistence.xml looks like this:

 <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="MogEntityLivedataPU" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>entity.Todo</class>
        <properties>
                <property name="javax.persistence.jdbc.url" value="jdbc:odbc:MogDev_livedata_ODBC"/>
                <property name="javax.persistence.jdbc.password" value=""/>
                <property name="javax.persistence.jdbc.driver" value="sun.jdbc.odbc.JdbcOdbcDriver"/>
                <property name="javax.persistence.jdbc.user" value=""/>
            <property name="javax.persistence.jdbc.user" value=""/>
    </properties>
      </persistence-unit>
    </persistence>


Any help is appreciated as to how I can fix this. Thank You!

Is This A Good Question/Topic? 0
  • +

Replies To: Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,259
  • Joined: 27-December 08

Re: Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

Posted 12 July 2012 - 11:31 AM

Moved to Java EE.
Was This Post Helpful? 0
  • +
  • -

#3 Metal Wing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 04-March 12

Re: Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

Posted 12 July 2012 - 11:52 AM

Minor update. If I add
<property name="eclipselink.ddl-generation" value="create-tables"/></properties>
to my persistence.xml, the error is this:

Internal Exception: java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Function argument value, type, or count is invalid.
Error Code: 901
Call: CREATE TABLE TODO (TDTDKEY VARCHAR NOT NULL, TDBILLABLE NUMBER(1), TDEMAILED NUMBER(1), TDFLATRATE NUMBER(1), TDADD_DATE DATE, TDADD_TERM VARCHAR, TDADD_TIME VARCHAR, TDADD_USER VARCHAR, TDCHG_DATE DATE, TDCHG_NUMB NUMBER(10), TDCHG_TERM VARCHAR, TDCHG_TIME VARCHAR, TDCHG_USER VARCHAR, TDDETAILS CLOB(2147483647), TDDATEDONE DATE, TDFOLLOWUP DATE, TDINTERNAL NUMBER(1), TDPRIVATE NUMBER(1), TDREQUIRED DATE, TDSRED NUMBER(1), TDTAKEN DATE, TDDESCRIP VARCHAR, TDPRIORITY NUMBER(10), TDCMKEY VARCHAR, TDCNKEY VARCHAR, TDJTKEY VARCHAR, TDPYKEY VARCHAR, TDURKEYAS VARCHAR, TDURKEYTB VARCHAR, PRIMARY KEY (TDTDKEY))
Query: DataModifyQuery(sql="CREATE TABLE TODO (TDTDKEY VARCHAR NOT NULL, TDBILLABLE NUMBER(1), TDEMAILED NUMBER(1), TDFLATRATE NUMBER(1), TDADD_DATE DATE, TDADD_TERM VARCHAR, TDADD_TIME VARCHAR, TDADD_USER VARCHAR, TDCHG_DATE DATE, TDCHG_NUMB NUMBER(10), TDCHG_TERM VARCHAR, TDCHG_TIME VARCHAR, TDCHG_USER VARCHAR, TDDETAILS CLOB(2147483647), TDDATEDONE DATE, TDFOLLOWUP DATE, TDINTERNAL NUMBER(1), TDPRIVATE NUMBER(1), TDREQUIRED DATE, TDSRED NUMBER(1), TDTAKEN DATE, TDDESCRIP VARCHAR, TDPRIORITY NUMBER(10), TDCMKEY VARCHAR, TDCNKEY VARCHAR, TDJTKEY VARCHAR, TDPYKEY VARCHAR, TDURKEYAS VARCHAR, TDURKEYTB VARCHAR, PRIMARY KEY (TDTDKEY))")


It kind of makes me wonder why it treats TDBILLABLE and some others as NUMBER when they are clearly LOGICAL... But that said, I can see that it is trying to create TDDETAILS as a CLOB(2147483647). After that it proceeds to the "Feature not available" error... So I usually don't have the table creation property in my persistence.xml
Was This Post Helpful? 0
  • +
  • -

#4 RCR  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 33
  • Joined: 04-July 12

Re: Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

Posted 15 July 2012 - 10:53 AM

Have you called TDDETAILS anywhere else? It would be helpful if you could show the whole code.

-RCR
Was This Post Helpful? 0
  • +
  • -

#5 Metal Wing  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 04-March 12

Re: Error when trying to access memo field (EclipseLink, JdbcOdbc, Clob)

Posted 16 July 2012 - 06:15 AM

View PostRCR, on 15 July 2012 - 10:53 AM, said:

Have you called TDDETAILS anywhere else? It would be helpful if you could show the whole code.

-RCR



Well, I attempted creating a new project that consists of literally 2 files - Entity (which I make into a jar) and a main class:

todo.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;


@Entity
@Table(name = "TODO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Todo.findAll", query = "SELECT c FROM Todo c")})
public class Todo implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "TDTDKEY")
    private String id;
    @Lob
    @Column(name = "TDDETAILS")
    private byte[] details;

    public byte[] getDetails() {
        return details;
    }

    public void setDetails(byte[] details) {
        this.details = details;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Todo)) {
            return false;
        }
        Todo other = (Todo) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Todo[ id=" + id + " ]";
    }
}



RetrieveMemo.java

package retrievememo;

import entity.Todo;
import java.util.List;
import javax.persistence.Query;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;

/**
 *
 * @author Denis
 */
public class RetrieveMemo {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        EntityManager entityManager = Persistence.createEntityManagerFactory("MemoEntityPU").createEntityManager();
        Query query = entityManager.createNamedQuery("Todo.findAll");
        List<Todo> resultList = query.getResultList();
        System.out.println("Memo1:>" + resultList.get(1).getDetails() + "<");

    }
}



Here is the full stack trace:

[EL Info]: 2012-07-16 09:10:14.382--ServerSession(20248218)--EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
[EL Info]: 2012-07-16 09:10:14.491--Not able to detect platform for vendor name [Visual FoxPro]. Defaulting to [org.eclipse.persistence.platform.database.DatabasePlatform]. The database dialect used may not match with the database you are using. Please explicitly provide a platform using property eclipselink.platform.class.name.
[EL Info]: 2012-07-16 09:10:15.851--ServerSession(20248218)--file:/Y:/NetBeansProjects/MemoEntity/build/classes/_MemoEntityPU login successful
[EL Warning]: 2012-07-16 09:10:16.899--UnitOfWork(6597453)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Feature is not available.
Error Code: 0
Call: SELECT TDTDKEY, TDDETAILS FROM TODO
Query: ReadAllQuery(name="Todo.findAll" referenceClass=Todo sql="SELECT TDTDKEY, TDDETAILS FROM TODO")
Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Feature is not available.
Error Code: 0
Call: SELECT TDTDKEY, TDDETAILS FROM TODO
Query: ReadAllQuery(name="Todo.findAll" referenceClass=Todo sql="SELECT TDTDKEY, TDDETAILS FROM TODO")
	at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.getObject(DatabaseAccessor.java:1237)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.fetchRow(DatabaseAccessor.java:999)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processResultSet(DatabaseAccessor.java:723)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:621)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
	at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
	at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
	at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2592)
	at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2551)
	at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:418)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1097)
	at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
	at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
	at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
	at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
	at retrievememo.RetrieveMemo.main(RetrieveMemo.java:26)
Caused by: java.sql.SQLException: [Microsoft][ODBC Visual FoxPro Driver]Feature is not available.
	at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:318)
	at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1678)
	at org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.getObjectFromResultSet(DatabasePlatform.java:1216)
	at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.getObject(DatabaseAccessor.java:1206)
	... 25 more
Java Result: 1
BUILD SUCCESSFUL (total time: 11 seconds)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1