Werner, Here is the complete jdo-config.xml file:
<jdo-conf> <database name="mydb" engine="mysql" > <driver url="jdbc:mysql://localhost:3306/" class-name="com.mysql.jdbc.Driver"> <param name="user" value="sa" /> <param name="password" value="password" /> </driver> <mapping href="mapping.xml" /> </database> <transaction-demarcation mode="local" /> </jdo-conf> ....and my mapping file: <mapping> <class name="project.Student" identity="studentID"> <map-to table="students" /> <field name="studentID" type="int"> <sql name="studentid" type="integer"/> </field> <field name="firstName" type="string"> <sql name="firstname" type="varchar" /> </field> <field name="lastName" type="string"> <sql name="lastname" type="varchar" /> </field> <field name="groups" type="string"> <sql name="groups" type="varchar" /> </field> </class> </mapping> Thanks John -----Original Message----- From: Werner Guttmann [mailto:[EMAIL PROTECTED] Sent: Monday, January 23, 2006 02:09 PM To: [email protected] Subject: Re: [castor-user] Connection to Database John, what does your complete JDO config file look like ? Regards Werner Guttmann John Greene wrote: > Werner, > > The database named "john" is a Pointbase database, which is not currently > supported by Castor, correct?? > > The Database named "mydb" is a mySQL database, which Castor does support. > > As I debug the program the Student class gets created and values are read; > however the runtime output: > SQL: INSERT INTO students (studentid,firstname,lastname,groups) VALUES > (?,?,?,?) suggest Castor does not see these values!! > > Thanks > John > > -----Original Message----- > From: Werner Guttmann [mailto:[EMAIL PROTECTED] > Sent: Monday, January 23, 2006 01:08 PM > To: [email protected] > Cc: Werner Guttmann > Subject: Re: [castor-user] Connection to Database > > > John, > > given your JDO config example from further above (read in the original > email that started this tread), I do believe that your database is named > "john" and not "mydb" ... ;-). > > Regards > Werner Guttmann > > John Greene wrote: > >>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] >>------------------------------------------------- >> >> > > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > > > > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- > > ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] ------------------------------------------------- ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------

