0 Replies Latest reply on Oct 17, 2003 2:26 PM by nithyaswam

    MS Access, Auto-Increment, Unsupported Operation Error

    nithyaswam Newbie

      Hi All:

      I am a beginner and I am working with CMP Entity Beans using Jboss, Lomboz Eclipse and MS Access 2000.

      I read all your messages for solutions to Auto increment and tried to implement all those solutions and now I am getting a new error java.lang.UnsupportedOperationException .. and the entity bean could not be created

      I am wondering if it is caused by the Auto INcrement

      I am unable to attach files to this forum. I dont know why.. But I am posting the Debug messages of the JBOSS Server below
      --------------------------
      15:51:21,225 DEBUG [Attendance]

      jar:file:/C:/Memorial/Jboss/jboss-3.2.1/server/all/tmp/deploy/server/all/deploy/IncomeMana

      ger.jar/49.IncomeManager.jar!/META-INF/jbosscmp-jdbc.xml found. Overriding defaults
      15:51:21,303 DEBUG [Attendance] Insert Entity SQL: INSERT INTO Attendance (AttendanceDate,

      ChildID, ChildStatus, AbsenceReason, Breakfast, Lunch, Snack) VALUES (?, ?, ?, ?, ?, ?, ?)
      15:51:21,303 DEBUG [Attendance] entity-command:

      [commandName=get-generated-keys,commandClass=class

      org.jboss.ejb.plugins.cmp.jdbc.jdbc3.JDBCGetGeneratedKeysCreateCommand,attributes={}]
      15:51:21,303 DEBUG [Attendance] Remove SQL: DELETE FROM Attendance WHERE AttendanceID=?
      15:51:21,303 INFO [Attendance] Table 'Attendance' already exists
      15:51:21,303 DEBUG [findByPrimaryKey] SQL: SELECT AttendanceID FROM Attendance WHERE

      AttendanceID=?
      15:51:21,303 DEBUG [Attendance] Added findByPrimaryKey query command for home interface
      15:51:21,303 DEBUG [findByPrimaryKey] SQL: SELECT AttendanceID FROM Attendance WHERE

      AttendanceID=?
      15:51:21,303 DEBUG [Attendance] Added findByPrimaryKey query command for local home

      interface
      15:51:21,303 DEBUG [findAll] EJB-QL: SELECT OBJECT(a) FROM myAttendance as a
      15:51:21,303 DEBUG [findAll] SQL: SELECT t0_a.AttendanceID FROM Attendance t0_a
      15:51:21,303 DEBUG [findByAttendanceDate] EJB-QL: SELECT OBJECT(a) FROM myAttendance a

      where a.attendanceDate = ?1
      15:51:21,319 DEBUG [findByAttendanceDate] SQL: SELECT t0_a.AttendanceID FROM Attendance

      t0_a WHERE t0_a.AttendanceDate = ?
      15:51:21,319 DEBUG [findByAttendanceDate] EJB-QL: SELECT OBJECT(a) FROM myAttendance a

      where a.attendanceDate = ?1
      15:51:21,319 DEBUG [findByAttendanceDate] SQL: SELECT t0_a.AttendanceID FROM Attendance

      t0_a WHERE t0_a.AttendanceDate = ?
      15:51:21,319 DEBUG [findAll] EJB-QL: SELECT OBJECT(a) FROM myAttendance as a
      15:51:21,319 DEBUG [findAll] SQL: SELECT t0_a.AttendanceID FROM Attendance t0_a
      15:51:21,319 INFO [EntityInstancePool] Starting
      15:51:21,319 INFO [EntityInstancePool] Started
      15:51:21,319 INFO [EntityContainer] Started
      15:51:21,319 INFO [StatelessSessionContainer] Starting
      15:51:21,350 INFO [StatelessSessionInstancePool] Starting
      15:51:21,350 INFO [StatelessSessionInstancePool] Started
      15:51:21,350 INFO [StatelessSessionContainer] Started
      15:51:21,350 INFO [EjbModule] Started
      15:51:21,350 INFO [EJBDeployer] Deployed:

      file:/C:/Memorial/Jboss/jboss-3.2.1/server/all/deploy/IncomeManager.jar
      15:51:21,381 INFO [MainDeployer] Deployed package:

      file:/C:/Memorial/Jboss/jboss-3.2.1/server/all/deploy/IncomeManager.jar
      15:51:53,553 INFO [STDOUT] Entering ejbCreate()
      15:51:53,569 INFO [STDOUT] Leaving ejbCreate()
      15:51:53,584 INFO [STDOUT] Entering ejbCreate()
      15:51:53,584 INFO [STDOUT] 2003-10-17
      15:51:53,584 INFO [STDOUT] Leaving ejbCreate()
      15:51:53,584 DEBUG [Attendance] Executing SQL: INSERT INTO Attendance (AttendanceDate,

      ChildID, ChildStatus, AbsenceReason, Breakfast, Lunch, Snack) VALUES (?, ?, ?, ?, ?, ?, ?)
      15:51:53,584 ERROR [Attendance] Could not create entity
      java.lang.UnsupportedOperationException
      at sun.jdbc.odbc.JdbcOdbcConnection.prepareStatement(JdbcOdbcConnection.java:1750)
      at

      org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:

      293)

      -----------------------

      Also my jbosscmp-jdbc.xml file is as below

      -------------
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jbosscmp-jdbc PUBLIC '-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN' 'http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd'>


      <jbosscmp-jdbc>

      java:/MSAccessmemorialDS
      <datasource-mapping>MSAccess</datasource-mapping>
      <preferred-relation-mapping>foreign-key</preferred-relation-mapping>



      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jbosscmp-jdbc-beans.xml
      that contains the markup for those beans.
      -->


      <ejb-name>Attendance</ejb-name>
      <table-name>Attendance</table-name>

      <cmp-field>
      <field-name>attendanceID</field-name>
      <column-name>AttendanceID</column-name>
      <auto-increment/>
      </cmp-field>
      <cmp-field>
      <field-name>attendanceDate</field-name>
      <column-name>AttendanceDate</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>childID</field-name>
      <column-name>ChildID</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>childStatus</field-name>
      <column-name>ChildStatus</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>absenceReason</field-name>
      <column-name>AbsenceReason</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>breakfast</field-name>
      <column-name>Breakfast</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>lunch</field-name>
      <column-name>Lunch</column-name>

      </cmp-field>
      <cmp-field>
      <field-name>snack</field-name>
      <column-name>Snack</column-name>

      </cmp-field>
      <entity-command name="get-generated-keys" class="org.jboss.ejb.plugins.cmp.jdbc.jdbc3.JDBCGetGeneratedKeysCreateCommand">
      </entity-command>



      </enterprise-beans>

      </jbosscmp-jdbc>

      -------------------

      and my ejbcreate() for the entity bean is
      -----------------------------
      public java.lang.Integer ejbCreate(java.sql.Date attDate,java.lang.Integer chID,java.lang.String chStatus,java.lang.String absReason, java.lang.String b, java.lang.String l, java.lang.String s) throws javax.ejb.CreateException {
      // EJB 2.0 spec says return null for CMP ejbCreate methods.
      // TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
      // setMyField("Something");
      System.out.println("Entering ejbCreate()");
      log.debug("ejbCreate '" + attDate + "' "+ chID+", version="+VERSION);
      System.out.println(attDate.toString());
      setAttendanceID(new Integer(0)) ;
      setAttendanceDate(attDate);
      setChildID(chID);
      setChildStatus(chStatus);
      setAbsenceReason(absReason);
      setBreakfast(b);
      setLunch(l);
      setSnack(s);
      System.out.println("Leaving ejbCreate()");
      return null;
      }

      -------------------

      Kindly go thru the code and help me Please!
      Thanks
      Nithya