Okay, I have come a long way and just got one more hurdle to get over:

This is the error message:

Jan 23, 2006 12:24:31 PM org.exolab.castor.jdo.engine.SQLEngine create
INFO: A fatal error occurred while creating/updating project.Student using
SQL: INSERT INTO students (studentid,firstname,lastname,groups) VALUES
(?,?,?,?)
java.sql.SQLException: No database selected
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
        at
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
        at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
        at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
        at
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
        at org.exolab.castor.jdo.engine.SQLEngine.create(SQLEngine.java:683)
        at
org.exolab.castor.persist.ClassMolder.create(ClassMolder.java:683)
        at org.exolab.castor.persist.LockEngine.create(LockEngine.java:486)
        at
org.castor.persist.AbstractTransactionContext.walkObjectsToBeCreated(Abstrac
tTransactionContext.java:805)
        at
org.castor.persist.AbstractTransactionContext.create(AbstractTransactionCont
ext.java:762)
        at
org.exolab.castor.jdo.engine.DatabaseImpl.create(DatabaseImpl.java:360)
        at project.MyCastor.CreateMedia(MyCastor.java:45)
        at project.Main.main(Main.java:27)
org.exolab.castor.jdo.PersistenceException: Nested error:
java.sql.SQLException: No database selected: No database selected


AND THID IS MY CODE IN WHICH THE DATABASE IS SELECTED:......................

        try
        {
            JDOManager jdo;
            JDOManager.loadConfiguration("jdo-config.xml");
            jdo = JDOManager.createInstance("mydb");

            /** lets do some processiong */
            Database db = jdo.getDatabase();

            System.out.println( db.isClosed() );

            db.begin();
            Student student = new Student(100, "John", "Doe", "Group A");
            db.create(student);
            db.commit();
        }
        catch (Exception e)
        {
            System.out.println(e);
        }

What could be wrong here?

Thanks
John


-----Original Message-----
From: Werner Guttmann [mailto:[EMAIL PROTECTED]
Sent: Monday, January 23, 2006 08:59 AM
To: [email protected]; [EMAIL PROTECTED]
Subject: RE: [castor-user] Connection to Database


John,

Can I take it that you have read (and understood .. ;-))
http://castor.codehaus.org/database-conf.html. As outlined there, you'll
need to adopt your JDO config file and add <jdo-conf> and
<transaction-demarcation> elements.

Regards
Werner Guttmann

wg> -----Original Message-----
wg> From: John Greene [mailto:[EMAIL PROTECTED]
wg> Sent: Monday, January 23, 2006 2:48 PM
wg> To: Castor User
wg> Subject: [castor-user] Connection to Database
wg>
wg> Hi,
wg>
wg> First I am a new user of Castor, and I am trying to get a
wg> connection to either mySQL or Pointbase database (not sure
wg> if the latter is supported).
wg> Anyhow I keep getting the following runtime error message
wg>
wg>
wg> org.exolab.castor.mapping.MappingException: Nested error:
wg> unable to find FieldDescriptor for 'driver' in
wg> ClassDescriptor of jdo-conf
wg>
wg> Database config file is as follows:
wg>
wg> <database name="john" engine="pointbase" >
wg>   <driver class-name="com.pointbase.jdbc.jdbcUniversalDriver"
wg>     url="jdbc:pointbase://localhost:9092/john" >
wg>     <param name="user" value="pbsysadmin"/>
wg>     <param name="password" value="pbsysadmin"/>
wg>   </driver>
wg>   <mapping href="mapping.xml" /mapping>
wg> </database>
wg>
wg>
wg>
wg> Mapping file is below:
wg>
wg> <mapping>
wg> <class name="project.student" identity="studentid">
wg>   <map-to table="students" />
wg>   <field name="studentid" type="integer">
wg>     <sql name="studentid" type="integer"/>
wg>   </field>
wg>
wg>   <field name="firstname" type="string">
wg>    <sql name="firstname" type="varchar" />
wg>   </field>
wg>
wg>   <field name="lastname" type="string">
wg>    <sql name="lastname" type="varchar" />
wg>   </field>
wg>
wg>   <field name="group" type="string">
wg>    <sql name="group" type="varchar" />
wg>   </field>
wg>
wg> </class>
wg> </mapping>
wg>
wg>
wg>
wg> -------------------------------------------------
wg> If you wish to unsubscribe from this list, please send an
wg> empty message to the following address:
wg>
wg> [EMAIL PROTECTED]
wg> -------------------------------------------------
wg>
wg>



-------------------------------------------------
If you wish to unsubscribe from this list, please 
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to