Michael,

it's a bit late here as well .. ;-), but please see below. I'll have another look 
tomorrow morning. Btw, what environment are you using ? Standalone or 
web/app server ? If e.g. web server, is the JDBC driver packaged within e.g. the web 
app ? 

Regards
Werner

On Wed, 16 Jun 2004 16:03:56 -0500, Grzemowski, Michal wrote:

>Well, here I am again ;-)
>
>Please forgive me if it is a silly mistake, but I am a newbe, it is 11PM and I am 
>still stuck on this ;-|
>
>I am experiencing 2 strange behaviors of JDO working with MySQL. First is that it 
>crashes or not depending if run normally or debugged step by step. 
The other is that it can't find the mapping for a class, despite the fact that it is 
there (although DB table has more fields than the class)...
>
>I would really appreciate any help - deadlines are closing...
>
>1. Erratic behavior:
>When I run my simple test application normally, then I get the following exception:
>toString: org.exolab.castor.jdo.DatabaseNotFoundException: Nested error: 
>java.lang.NullPointerException
>Stack trace:
>org.exolab.castor.jdo.JDO.getDatabase(JDO.java:605)
>castorTest.testJDO(castorTest.java:81)
>castorTest.main(castorTest.java:26)
>
>I found out that it is really thrown in line 283 of DatabaseRegistry.java - on the 
>following line:
>dbs = new DatabaseRegistry( database.getName(), mapping.getResolver( Mapping.JDO, 
>factory ), factory, database.getDriver().getUrl(), props );
        
>
>Surprisingly, when I debug it step by step, then it goes through and gets the 
>Database object.
>
>Any ideas what can it be? I am puzzled.
>
>2. Mapping not found
>But even if I get through getDatabase, then another exception is thrown, when I try 
>to define a query:
>OQLQuery query = db.getOQLQuery("SELECT s FROM LFSMarkets s WHERE searchTime=$1 AND 
>marketOrig=$2 AND marketDest=$3");
>
>The exception is:
>toString: org.exolab.castor.jdo.QueryException: Could not find mapping for class 
>LFSMarkets
>Stack trace:
>org.exolab.castor.jdo.oql.ParseTreeWalker.checkFromPart(ParseTreeWalker.java:305)
>org.exolab.castor.jdo.oql.ParseTreeWalker.checkErrors(ParseTreeWalker.java:222)
>org.exolab.castor.jdo.oql.ParseTreeWalker.<init>(ParseTreeWalker.java:137)
>org.exolab.castor.jdo.engine.OQLQueryImpl.create(OQLQueryImpl.java:261)
>org.exolab.castor.jdo.engine.DatabaseImpl.getOQLQuery(DatabaseImpl.java:439)
>castorTest.testJDO(castorTest.java:86)
>castorTest.main(castorTest.java:26)
>
>Gory details follow:
>
>Mapping.LFSMarkets.xml:
>    <mapping>
>         <class name="LFSMarkets" identity="searchTime marketOrig marketDesc 
> advPurchase satNightStay">
>              <map-to table="LFSMarkets"/>
>              <field name="searchTime" type="java.sql.Timestamp" direct="true">
>                  <sql name="SearchTime"/>
>              </field>
>              <field name="marketOrig" type="string" direct="true">
>                  <sql name="MarketOrig" type="char"/>
>              </field>
>              <field name="marketDest" type="string" direct="true">
>                  <sql name="MarketDest" type="char"/>
>              </field>
>              <field name="advPurchase" type="short" direct="true">
>                  <sql name="AdvPurchase" type="smallint"/>
>              </field>
>              <field name="satNightStay" type="byte" direct="true">
>                  <sql name="SatNightStay" type="tinyint"/>
>              </field>
>         </class>
>  </mapping>
>
>Config file:
><database name="JRIntl" engine="mysql" >
>    <driver url="jdbc:mysql://rm.xxxxx.com:3306/JRIntl" 
> class-name="com.mysql.jdbc.Driver">
>         <param name="user" value="xx" />
>         <param name="password" value="xxxxxxxxx" />
>    </driver>
>    <mapping href="Mapping.LFSMarkets.xml" />
></database>
>
>My test code, that is executed:
>               JDO      jdo;
>               Database db;
>               jdo = new JDO();
>               jdo.setDatabaseName( "JRIntl" );
>               jdo.setConfiguration( "MySQL.xml" );
>               jdo.setClassLoader(jdo.getClass().getClassLoader());

Can you please move that line in front of the call to JDO.setConfiguration () just to 
see whether it makes a difference ... 

>               try
>               {
>                       db = jdo.getDatabase();
>                       db.begin();
>                       OQLQuery query = db.getOQLQuery("SELECT s FROM LFSMarkets s 
> WHERE searchTime=$1 AND marketOrig=$2 
AND marketDest=$3");
>                       query.bind("2004-05-11 10:34:00");
>                       query.bind("DFW");
>                       query.bind("AMS");
>                       QueryResults results = query.execute();
>                       System.out.println(results.size());
>                       LFSMarkets myShop = (LFSMarkets)results.next();
>                       db.commit();
>                       db.close();
>               }
>
>
>Table LFSMarkets:
>
>SearchTime     datetime                        PRI
>MarketOrig     char(3)                 PRI
>MarketDest     char(3)                 PRI
>AdvPurchase    smallint(6)                     PRI
>SatNightStay   tinyint(1)              PRI
>DepartDate     date
>ReturnDate     date
>TotalSearchTime        time
>RetrieverCount smallint(6)
>RunID  varchar(30)     
>ZipFileProcessed       tinyint(1)
>LowestFare     decimal(8,2)
>
>Thanks,
>
>Michal
>
>-- 
>Michal Grzemowski
>Programmer/Analyst
>
>Sabre Polska Sp z o.o.
>ul. Cystersow 13A
>31-553 Krakow, Poland
>
>tel: +48 12 295 9056
>fax: +48 12 295 9001
>----------------------
>
>



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to