3 Replies Latest reply on May 15, 2003 12:56 AM by 3004

    Problem retrieving objects from the database!

    3004
      hello,
      since several days I have been trying to understand and test Kodo JDO.
      Because I am relatively new to programming in Java and JDO I have some
      problems in getting started. I am using JBuilder8.0 and the Kodo plugin to
      store objects in a MS SQL Server database (actually it is a MSDE database).
      Moreover I am using Sun's JDBC-ODBC bridge to connect to the database (I
      tried Microsofts SQL Server JDBC driver, but then I got the problem "Not
      associated with a trusted SQL Server connection", which I found out is a
      specific MSDE problem). Nevertheless I succeeded in storing several simple
      (that isb no relations to other objects) Person objects. Next, I tried to
      retrieve all these objects from the database, using:

      Extent Employees = pm.getExtent(Person.class, false);
      Iterator iter = Employees.iterator();
      while(iter.hasNext()) {
      Person obj = (Person) iter.next();
      System.out.println(obj.toString());
      }

      but as soon as the debugger gets at the "iter.hasNext()" line I get an
      exception stacktrace which is included below. It cannot seem to find my
      class Person in package example, although all the objects are in the
      "PersonX" table with the value "example.Person" in the JDOCLASSX field. (by
      the way at line 33178 "example.Person " isnt trimmed??) I have absolutely
      no idea what is causing this. Does anyone have a solution for this problem,
      because I really want to continu testing....?!

      sincerely,
      Christiaan


      32607 [main] INFO jdbc.JDBC - [ C:9104244; T:31737213; D:4999131 ] get
      [com.solarmetric.datasource.PoolConnection@8aeb74[[requests=522;size=4;max=1
      00;hits=517;created=5;redundant=0;overflow=0;new=5;leaked=0;unavailable=0]]]
      from [com.solarmetric.datasource.DataSourceImpl$SortablePool[min=1; max=80;
      size=2; taken=0]]

      32607 [main] INFO jdbc.SQL - [ C:9104244; T:31737213; D:4999131 ] preparing
      statement <5263041>: SELECT DISTINCT PERSONX.JDOCLASSX FROM PERSONX

      32607 [main] INFO jdbc.SQL - [ C:9104244; T:31737213; D:4999131 ] executing
      statement <5263041>: [reused=1;params={}]

      33178 [main] WARN kodo.Runtime - Unknown subclass "example.Person
      " for class query against "class example.Person".

      javax.jdo.JDODataStoreException: Type "example.Person
      " is referenced in the database, but does not exist.
      NestedThrowables:
      javax.jdo.JDOFatalUserException: Could not resolve the class name
      "example.Person
      ". None of the following ClassLoaders could locate the class resource:
      "com.solarmetric.kodo.util.MultiLoaderClassResolver@4b224e loaders:
      [sun.misc.Launcher$AppClassLoader@4b222f]; thread's context class loader:
      sun.misc.Launcher$AppClassLoader@4b222f",
      "sun.misc.Launcher$AppClassLoader@4b222f".
      NestedThrowables:
      javax.jdo.JDOFatalUserException: Could not resolve the class name
      "example.Person
      ". None of the following ClassLoaders could locate the class resource:
      "[sun.misc.Launcher$AppClassLoader@4b222f]",
      "sun.misc.Launcher$AppClassLoader@4b222f".
      NestedThrowables:
      java.lang.ClassNotFoundException: example/Person

      java.lang.ClassNotFoundException: example/Person
      java.lang.ClassNotFoundException: example/Person

      at
      com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl.getType(Subcla
      ssProviderImpl.java:122)

      at
      com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl.getSubclasses(
      SubclassProviderImpl.java:260)

      at
      com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.addSubclassConditions(
      ClassMapping.java:1239)

      at
      com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.selectPrimaryMappings(
      ClassMapping.java:1218)

      at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
      reManager.java:707)

      at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getResultList(JDBCExtent.j
      ava:64)

      at
      com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getIterator(JDBCExtent.jav
      a:46)

      at
      com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.newIterator
      (ExtentImpl.java:242)

      at serp.util.MultiIterator.setIterator(MultiIterator.java:70)

      at serp.util.MultiIterator.hasNext(MultiIterator.java:25)

      at
      com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.hasNext(Ext
      entImpl.java:218)

      at example.MainClass.GetEmployees(MainClass.java:37)

      at example.MainClass.main(MainClass.java:118)


      just to be complete, kodo.properties:
      com.solarmetric.kodo.DataCacheClass=
      com.solarmetric.kodo.PersistenceManagerClass=com.solarmetric.kodo.runtime.Pe
      rsistenceManagerImpl
      com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout=60
      com.solarmetric.kodo.impl.jdbc.DictionaryClass=com.solarmetric.kodo.impl.jdb
      c.schema.dict.SQLServerDictionary
      com.solarmetric.kodo.impl.jdbc.SQLExecutionListenerClass=
      com.solarmetric.kodo.impl.jdbc.StatementCacheMaxSize=100
      com.solarmetric.kodo.impl.jdbc.SynchronizeSchema=true
      com.solarmetric.kodo.impl.jdbc.TransactionIsolation=NONE
      com.solarmetric.kodo.impl.jdbc.UseBatchedStatements=false
      com.solarmetric.kodo.impl.jdbc.WarnOnPersistentTypeFailure=true
      javax.jdo.PersistenceManagerFactoryClass=com.solarmetric.kodo.impl.jdbc.JDBC
      PersistenceManagerFactory
      javax.jdo.option.ConnectionDriverName=sun.jdbc.odbc.JdbcOdbcDriver
      javax.jdo.option.ConnectionPassword=
      javax.jdo.option.ConnectionURL=jdbc\:odbc\:JDODatabase
      javax.jdo.option.ConnectionUserName=
      javax.jdo.option.MaxPool=80
      javax.jdo.option.MinPool=1
      javax.jdo.option.MsWait=5000
      javax.jdo.option.Multithreaded=true


        • 1. Re: Problem retrieving objects from the database!
          3004
          It sounds like the extra spaces at the end of the class name in the
          database might well be causing the problem.

          We don't test against the JDBC-ODBC bridge. I wouldn't be surprised if
          somehow somebody was sneaking in the extra spaces for some reason.

          I'd suggest that you create a custom SubclassProvider that extends ours
          and simply trims any whitespace off the end of the classname before
          attempting to instantiate the class.

          For more details about subclass providers, see our docs and our javadoc
          for the com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProvider and
          com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl classes.

          -Patrick

          On Tue, 13 May 2003 12:55:00 -0400, Christiaan wrote:
          hello,
          since several days I have been trying to understand and test Kodo JDO.
          Because I am relatively new to programming in Java and JDO I have some
          problems in getting started. I am using JBuilder8.0 and the Kodo plugin
          to store objects in a MS SQL Server database (actually it is a MSDE
          database). Moreover I am using Sun's JDBC-ODBC bridge to connect to the
          database (I tried Microsofts SQL Server JDBC driver, but then I got the
          problem "Not associated with a trusted SQL Server connection", which I
          found out is a specific MSDE problem). Nevertheless I succeeded in
          storing several simple (that isb no relations to other objects) Person
          objects. Next, I tried to retrieve all these objects from the database,
          using:

          Extent Employees = pm.getExtent(Person.class, false); Iterator iter
          = Employees.iterator(); while(iter.hasNext()) {
          Person obj = (Person) iter.next();
          System.out.println(obj.toString());
          }
          }
          but as soon as the debugger gets at the "iter.hasNext()" line I get an
          exception stacktrace which is included below. It cannot seem to find my
          class Person in package example, although all the objects are in the
          "PersonX" table with the value "example.Person" in the JDOCLASSX field.
          (by the way at line 33178 "example.Person " isnt trimmed??) I have
          absolutely no idea what is causing this. Does anyone have a solution for
          this problem, because I really want to continu testing....?!

          sincerely,
          Christiaan


          32607 [main] INFO jdbc.JDBC - [ C:9104244; T:31737213; D:4999131 ] get
          [com.solarmetric.datasource.PoolConnection@8aeb74[[requests=522;size=4;max=1
          00;hits=517;created=5;redundant=0;overflow=0;new=5;leaked=0;unavailable=0]]]
          from [com.solarmetric.datasource.DataSourceImpl$SortablePool[min=1;
          max=80; size=2; taken=0]]

          32607 [main] INFO jdbc.SQL - [ C:9104244; T:31737213; D:4999131 ]
          preparing statement <5263041>: SELECT DISTINCT PERSONX.JDOCLASSX FROM
          PERSONX

          32607 [main] INFO jdbc.SQL - [ C:9104244; T:31737213; D:4999131 ]
          executing statement <5263041>: [reused=1;params={}]

          33178 [main] WARN kodo.Runtime - Unknown subclass "example.Person " for
          class query against "class example.Person".

          javax.jdo.JDODataStoreException: Type "example.Person " is referenced in
          the database, but does not exist. NestedThrowables:
          javax.jdo.JDOFatalUserException: Could not resolve the class name
          "example.Person
          ". None of the following ClassLoaders could locate the class resource:
          "com.solarmetric.kodo.util.MultiLoaderClassResolver@4b224e loaders:
          [sun.misc.Launcher$AppClassLoader@4b222f]; thread's context class
          loader: sun.misc.Launcher$AppClassLoader@4b222f",
          "sun.misc.Launcher$AppClassLoader@4b222f". NestedThrowables:
          javax.jdo.JDOFatalUserException: Could not resolve the class name
          "example.Person
          ". None of the following ClassLoaders could locate the class resource:
          "[sun.misc.Launcher$AppClassLoader@4b222f]",
          "sun.misc.Launcher$AppClassLoader@4b222f". NestedThrowables:
          java.lang.ClassNotFoundException: example/Person

          java.lang.ClassNotFoundException: example/Person
          java.lang.ClassNotFoundException: example/Person

          at
          com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl.getType(Subcla
          ssProviderImpl.java:122)

          at
          com.solarmetric.kodo.impl.jdbc.ormapping.SubclassProviderImpl.getSubclasses(
          SubclassProviderImpl.java:260)

          at
          com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.addSubclassConditions(
          ClassMapping.java:1239)

          at
          com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping.selectPrimaryMappings(
          ClassMapping.java:1218)

          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.executeQuery(JDBCSto
          reManager.java:707)

          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getResultList(JDBCExtent.j
          ava:64)

          at
          com.solarmetric.kodo.impl.jdbc.runtime.JDBCExtent.getIterator(JDBCExtent.jav
          a:46)

          at
          com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.newIterator
          (ExtentImpl.java:242)

          at serp.util.MultiIterator.setIterator(MultiIterator.java:70)

          at serp.util.MultiIterator.hasNext(MultiIterator.java:25)

          at
          com.solarmetric.kodo.runtime.ExtentImpl$TransactionAwareIterator.hasNext(Ext
          entImpl.java:218)

          at example.MainClass.GetEmployees(MainClass.java:37)

          at example.MainClass.main(MainClass.java:118)


          just to be complete, kodo.properties:
          com.solarmetric.kodo.DataCacheClass=
          com.solarmetric.kodo.PersistenceManagerClass=com.solarmetric.kodo.runtime.Pe
          rsistenceManagerImpl
          com.solarmetric.kodo.impl.jdbc.ConnectionTestTimeout=60
          com.solarmetric.kodo.impl.jdbc.DictionaryClass=com.solarmetric.kodo.impl.jdb
          c.schema.dict.SQLServerDictionary
          com.solarmetric.kodo.impl.jdbc.SQLExecutionListenerClass=
          com.solarmetric.kodo.impl.jdbc.StatementCacheMaxSize=100
          com.solarmetric.kodo.impl.jdbc.SynchronizeSchema=true
          com.solarmetric.kodo.impl.jdbc.TransactionIsolation=NONE
          com.solarmetric.kodo.impl.jdbc.UseBatchedStatements=false
          com.solarmetric.kodo.impl.jdbc.WarnOnPersistentTypeFailure=true
          javax.jdo.PersistenceManagerFactoryClass=com.solarmetric.kodo.impl.jdbc.JDBC
          PersistenceManagerFactory
          javax.jdo.option.ConnectionDriverName=sun.jdbc.odbc.JdbcOdbcDriver
          javax.jdo.option.ConnectionPassword=
          javax.jdo.option.ConnectionURL=jdbc\:odbc\:JDODatabase
          javax.jdo.option.ConnectionUserName=
          javax.jdo.option.MaxPool=80
          javax.jdo.option.MinPool=1
          javax.jdo.option.MsWait=5000
          javax.jdo.option.Multithreaded=true
          --
          Patrick Linskey
          SolarMetric Inc.
          • 2. Re: Problem retrieving objects from the database!
            3004
            thnx,
            the extra spaces are indeed the problem! Being a newby, writing my own
            SubclassProvider doesnt seem to be a very inviting solution ;) (by the way
            is source code included when buying a licence? It usually helps to see how
            the experts wrote the various classes...)

            I have solved the problem, which may be interesting to other MSDE users, by
            using the "com.microsoft.jdbc.sqlserver.SQLServerDriver". The problem loggin
            in via the JDBC driver on the MSDE is solved by installing the MSDE SP3.
            Doing this, and setting the authentication mode to "mixed mode", the bug in
            my previous MSDE version with "Not associated with a trusted SQL Server
            connection" was solved, and I can now store and retrieve the objects.
            However, I get the following exception, related to closing the resultset,
            frequently. Luckilly, the program continues, but is there anyway to avoid
            the exception?

            Christiaan

            3234 [main] INFO jdbc.SQL - [ C:1067475; T:31737213; D:8180602 ] preparing
            statement <25942001>: SELECT GETDATE()

            3244 [main] INFO jdbc.SQL - [ C:1067475; T:31737213; D:8180602 ] executing
            statement <25942001>: [reused=1;params={}]

            3915 [main] WARN jdbc.JDBC - [ C:1067475; T:31737213; D:8180602 ] Error
            when closing Statement/ResultSet

            java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
            JDBC][SQLServer]sp_cursorclose: The cursor identifier value provided
            (abcdef0) is not valid.

            at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

            at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown
            Source)

            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown
            Source)

            at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown
            Source)

            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)

            at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.closeCursor(Unknown
            Source)

            at
            com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.completeRowProcessing(Unkn
            own Source)

            at com.microsoft.jdbc.sqlserver.SQLServerImplResultSet.close(Unknown
            Source)

            at com.microsoft.jdbc.base.BaseResultSet.close(Unknown Source)

            at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown
            Source)

            at com.microsoft.jdbc.base.BaseStatement.close(Unknown Source)

            at com.microsoft.jdbc.base.BasePreparedStatement.close(Unknown Source)

            at
            com.solarmetric.datasource.StatementWrapper.close(StatementWrapper.java:201)

            at
            com.solarmetric.datasource.PreparedStatementCache$CachePreparedStatement.des
            troy(PreparedStatementCache.java:278)

            at
            com.solarmetric.datasource.PreparedStatementCache$CachePreparedStatement.clo
            se(PreparedStatementCache.java:350)

            at
            com.solarmetric.kodo.impl.jdbc.schema.dict.AbstractDictionary.isClosed(Abstr
            actDictionary.java:1887)

            at
            com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.getConnectionFromFact
            ory(SQLExecutionManagerImpl.java:186)

            at
            com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.getConnection(SQLExec
            utionManagerImpl.java:146)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.getConnection(SchemaTool.ja
            va:126)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool$LocalSchemaCache.cacheTable
            s(SchemaTool.java:1413)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool$LocalSchemaCache.<init>(Sch
            emaTool.java:1406)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.getSchemaCache(SchemaTool.j
            ava:157)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.refreshTable(SchemaTool.jav
            a:484)

            at
            com.solarmetric.kodo.impl.jdbc.schema.DBSequenceFactory.initializeSchema(DBS
            equenceFactory.java:130)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.refreshSequenceTables(Schem
            aTool.java:393)

            at
            com.solarmetric.kodo.impl.jdbc.schema.SchemaTool.refresh(SchemaTool.java:340
            )

            at
            com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory.synchronizeSche
            ma(JDBCPersistenceManagerFactory.java:557)

            at
            com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory.registerClassIn
            ternal(JDBCPersistenceManagerFactory.java:458)

            at
            com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory.flushDeferredRe
            gistrations(JDBCPersistenceManagerFactory.java:510)

            at
            com.solarmetric.kodo.impl.jdbc.JDBCPersistenceManagerFactory.configurePersis
            tenceManager(JDBCPersistenceManagerFactory.java:665)

            at
            com.solarmetric.kodo.runtime.PersistenceManagerFactoryImpl.newPersistenceMan
            ager(PersistenceManagerFactoryImpl.java:593)

            at
            com.solarmetric.kodo.runtime.PersistenceManagerFactoryImpl.getPersistenceMan
            ager(PersistenceManagerFactoryImpl.java:150)

            at
            com.solarmetric.kodo.runtime.PersistenceManagerFactoryImpl.getPersistenceMan
            ager(PersistenceManagerFactoryImpl.java:118)

            at example.MainClass.getPersistenceManager(MainClass.java:105)

            at example.MainClass.PersistPerson(MainClass.java:61)

            at example.MainClass.main(MainClass.java:111)


            • 3. Re: Problem retrieving objects from the database!
              3004
              See our FAQ regarding this driver issue.

              http://faq.solarmetric.com/external-fom-serve/cache/42.html

              Basically you can ignore it and turn down the logging:
              log4j.category.com.solarmetric.kodo.impl.jdbc.JDBC=INFO, console


              Also note that with most of our plugins, you shouldn't start from scratch.
              Look at the default listed in the configuration portion of the
              documenation for the plugin you want to alter, lookup the JavaDoc, and
              just extend the default class and override methods that need to be changed.



              On Wed, 14 May 2003 16:56:03 +0200, Christiaan wrote:
              thnx,
              the extra spaces are indeed the problem! Being a newby, writing my own
              SubclassProvider doesnt seem to be a very inviting solution ;) (by the way
              is source code included when buying a licence? It usually helps to see how
              the experts wrote the various classes...)

              I have solved the problem, which may be interesting to other MSDE users, by
              using the "com.microsoft.jdbc.sqlserver.SQLServerDriver". The problem loggin
              in via the JDBC driver on the MSDE is solved by installing the MSDE SP3.
              Doing this, and setting the authentication mode to "mixed mode", the bug in
              my previous MSDE version with "Not associated with a trusted SQL Server
              connection" was solved, and I can now store and retrieve the objects.
              However, I get the following exception, related to closing the resultset,
              frequently. Luckilly, the program continues, but is there anyway to avoid
              the exception?

              Christiaan