I'm trying to get a connection to a database with the following code;

    try
    {
      Mapping mapping = new Mapping( getClass().getClassLoader() );
      mapping.loadMapping( getClass().getResource( "mapping.xml" ) );

      JDO jdo = new JDO();
      jdo.setDatabaseName( "mydb" );
      jdo.setConfiguration( getClass().getResource( "database.xml" ).toString() );

// Test to see if we can get Database object
      jdo.getDatabase();
    }
    catch ( Exception e )
    {
      e.printStackTrace();
    }


Where I call jdo.getDatabase() I get; 

        MappingException: must call loadMapping first

Thought I had?!

Any ideas where I should be looking?  The database.xml file contains;

  <database name="mydb" engine="sybase">
    <driver class-name="com.sybase.jdbc2.jdbc.SybDriver"
            url="jdbc:sybase:Tds:dev1:20111/mydb">
      <param name="user"     value="user" />
      <param name="password" value="secret" />
    </driver>
  </database>

And the mapping.xml file contains;

  <class name="jdo.Customer"
         identity="custNum">
    <description>Customer</description>
    <map-to table="my_view" xml="customer" />
    <field name="custNum" type="integer" >
      <sql name="cust_num" type="integer"/>
      <xml node="attribute"/>
    </field>
    <field name="custShortName" type="string">
      <sql name="cust_short_name" type="varchar" />
      <xml node="text" />
    </field>
  </class>

The only thing I'm doing different is using a Sybase view instead of a table..
Thanks,
Rob Pieper

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

Reply via email to