JSP - Auto increment Oracle

Hello,
I've created some JSP pages with JDeveloper. When I want to create a new record in a table, then have I to fill in an unique ID for this record. Is it possible to get this field automatically filled in with an unique ID ? With Oracle, it's not possible to have an auto increment field. The solution I know, is to use a sequence and a trigger. But I doesn't want to use a trigger. Is there an other possibility ?
Greetz, Joris

It works! I've created a trigger to call the sequence to the primary key field and now it's populating that column properly.
Just one more doubt about it: I've imported some data from my old Access 2003 database to the new XE database, but when I insert a new record in the table, my sequence doesn't retrieve the last value from the primary key column + 1, it's recording straight from position 1 forward. The sequence created automatically during db migration is this one:
CREATE SEQUENCE "LOG_ID_LOG_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE
The problem with this sequence is that it doesn't see that I've migrated some data to this table before using it, so it's starting with value 1. How can I alter this sequence so it will always get the last (highest) value from my PK column + 1 before interting a new record to the table?
Thanks again!
Regards,
Roger.

Similar Messages

  • Auto-increment  identity column through procedure in oracle 10g on windows

    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary key

    Hi,
    SNEHA RK wrote:
    Hi,
    I need identity primary key which should be auto increment before while inserting data into table.
    for this i had use sequence and then trigger to increment it.Right. Some database products have auto-increment columns, and they are really handy. Unfortunately, Oracle does not have auto-increment columns. A sequence is an auto-increment object, and it's the right way to automatically generate unique identifiers, but you need to explicity reference the sequence, either in you DML statements, or in a trigger that will automatically fire before a DML statement.
    but now i need to increment it in Procedure, while my procedure is having code to insert data in same table which has primary keyAre you saying that you need to increment the sequence, completely aside from INSERTing into the table?
    If so, just reference sequence_name.NEXTVAL wherever you want to. In PL/SQL, you can say
    SELECT  sequence_name.NEXTVAL
    INTO    number_variable
    FROM    dual;This works in any version of Oracle, but starting in Oracle 11, you also have the option of referencing te sequence without using dual, or any other table.
    I hope this answers your question.
    If not, post a complete script that people can run to re-create the problem and test their ideas.
    For example:
    -- Here are the table and the seqauence that I created:
    CREATE TABLE table_x ...
    CREATE SEQUENCE ...
    -- Here is the BEFORE INSERT trigger I wrote:
    CREATE OR REPLACE TRIGGER ...
    -- The trigger works exactly how I want it to in statements like this:
    INSERT INTO table_x ...
    -- So there are no problems (that I know of) with anything up to this point.
    -- Now I want to use the same sequence to ...
    -- so that when I execute a statement like this
    -- then the next time  I add a new row to the orginal table, like this
    INSERT INTO table_x ...
    -- then the contents of table_x should be ... because ...

  • How to use "Auto increment" in temp table Oracle

    Pleas tell me yaar,
    In MS Sql for Auto increment i am using like this "seqid int identity" for temp table
    t_seq_tbl table(seqid int identity,EVENT_SEQ_NO varchar(30))
    In oracle how to use....

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Auto Increment ID Field Table in the Oracle Database (insert new record)

    I have been using the MySQL. And the ID field of the database table is AUTO INCREMENT. When I insert a new record into a database table, I can have a statement like:
       public void createThread( String receiver, String sender, String title,
                                 String lastPostMemberName, String threadTopic,
                                 String threadBody, Timestamp threadCreationDate,
                                 Timestamp threadLastPostDate, int threadType,
                                 int threadOption, int threadStatus, int threadViewCount,
                                 int threadReplyCount, int threadDuration )
                                 throws MessageDAOSysExceptionand I do not have to put the ID variable in the above method. The table will give the new record an ID number that is equivalent to the ID number of the last record plus one automatically.
    Now, I am inserting a new record into an Oracle database table. I am told that I cannot do what I am used to doing with the MySQL database.
    How do I revise the createThread method while I have no idea about what the next sequence number shall be?

    I am still very confused; in particular, the Java part. Let me try again.
    // This part is for the database table creation
    -- Component primary key sequence
    CREATE SEQUENCE dhsinfo_page_content_seq
        START WITH 0;
    -- Trigger for updating the Component primary key
    CREATE OR REPLACE TRIGGER DHSInfoPageContent_INSERT_TRIGGER
        BEFORE INSERT ON DHSInfoPageContent //DHSInfoPageContent is the table name
        FOR EACH ROW WHEN (new.ID IS NULL) // ID is the column name for auto increment
        BEGIN
            SELECT dhsinfo_page_content_seq.Nextval
            INTO :ID
            FROM DUAL;
        END;/I am uncertain what to do with my Java code. (I have been working with the MySQL. Changing to the Oracle makes me very confused.
       public void updateContent( int groupID, String pageName, int componentID,
                                  String content, Timestamp contentCreationDate )
                                   throws contentDAOSysException
       // The above Java statement does not have a value to insert into the ID column
       // in the DHSInfoPageContent table
          Connection conn = null;
          PreparedStatement stmt = null;
          // what to do with the INSERT INTO below.  Note the paramether ID.
          String insertSQL = "INSERT INTO DHSInfoPageContent( ID, GroupID, Name, ComponentID, Content, CreationDate ) VALUES (?, ?, ?, ?, ?, ?)";
          try
             conn = DBConnection.getDBConnection();
             stmt = conn.prepareStatement( insertSQL );
             stmt.setInt( 1, id ); // Is this Java statement redundant?
             stmt.setInt( 2, groupID );
             stmt.setString( 3, pageName );
             stmt.setInt( 4, componentID );
             stmt.setString( 5, content );
             stmt.setTimestamp( 6, contentCreationDate );
             stmt.executeUpdate();
           catch
           finally

  • Is there a auto-increment data type in Oracle

    Is there a auto-increment data type in Oracle ?
    How to do it if there is no auto-increment data type in Oracle ?
    null

    jackie (guest) wrote:
    : Is there a auto-increment data type in Oracle ?
    : How to do it if there is no auto-increment data type in Oracle
    Hi,
    I think you need unique ID's, for this purpose you use sequences
    in Oracle. Example:
    create table xy (
    id number,
    name varchar2(100)
    alter table xy
    add constraint xy_pk primary key(id);
    create sequence xy_seq start with 1 maxvalue 99999999999;
    (there are many other options for create sequence)
    create or replace trigger xy_ins_trg
    before insert on xy
    for each row
    begin
    select xy_seq.nextval
    into :new.id
    from dual;
    end;
    This produces a unique value for the column id at each insert.
    Hope this will help.
    peter
    null

  • Hibernate data insertion not working with oracle auto increment

    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.pojo.Example
    at org.hibernate.id.Assigned.generate(Assigned.java:33)
    at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:99)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
    at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
    at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
    at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
    at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
    at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
    at hibernetsample.Main.main(Main.java:30)

    >
    hi i have created a table and the id is set to auto increment by a sequence trigger pair
    when i manually giving value to id its working fine
    but when i tried without maually giving the id i am getting this error
    org.hibernate.id.Assigned
    >
    That is because you are using the hibernate 'assigned' generator which, by definition
    >
    lets the application to assign an identifier to the object before save() is called.
    This is the default strategy if no <generator> element is specified.
    >
    For your use case you can use the 'sequence' generator.
    The valid generator options and one way to use a sequence generator is shown in this article
    http://www.hibernate-training-guide.com/identifiers-generators.html
    The hibernate section of this article also uses a trigger with sequence generator
    http://blog.lishman.com/2009/02/auto-generated-primary-keys-in-oracle.html
    You should check the hibernate documention and tutorial for examples or search 'hibernate generator sequence example'

  • Auto increment numbers in Oracle 8i

    Hi all,
    How to have an auto increment number as a primary key of a table in Oracel 8i(8.1.7) ?. Is it possible to specify to use a sequence as a column ?
    Antony Paul

    You can create a BEFORE INSERT trigger that uses the sequence to populate the primary key column. If you are coming from SQL Server, that's the closest approximation to an IDENTITY column.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to use auto-increment and search option for MS Access DB

    Dear All,
               I have configured our invoice in Adobe Livecycle and connected it to MS Acess 2007 as per http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/.
    All is working fine, I can insert, retrieve data from DB to invoice and vice versa.
    Now I want few things to be implemented on our invoice.
    When ever I open our invoice, it populate the first entry from DB, Is it possible to populate the last entry ?
    Auto increment invoice number from MS Access DB every time we open our invoice after save.
    How to implement search option from DB for invoice number ?
    Please let me know if someone can provide me help on my scenario, so that I can share more stuff related to invoice and DB.
    Look forward to hearing soon from experts and other team members.
    Thanks & Regards
    Riyad...

    As far as I know there is not any auto increment data type in Oracle. Instead of this you should create a sequence and get the next value of the sequence while creating a row in your table.
    CREATE SEQUENCE Test_Sequence ;
    CREATE TABLE Test_Table ( Id NUMBER , Foo VARCHAR2(4) ) ;
    ALTER TABLE Test_Table ADD CONSTRAINT Test_Table_PK_Id PRIMARY KEY ( Id ) ;
    INSERT INTO Test_Table ( Id , Information ) VALUES ( Test_Sequence.NEXTVAL , 'FOO' ) ;

  • Trying to create cmp correctly(auto-increment);error while running

    I am using the latest versions of Jboss(4.0.5.GA) and Lomboz(R-3.2-200610201336) along with SQL Server 2005 and Microsoft's SQL Server 2005 JDBC driver.
    Lomboz used xdoclet to create the java files based on the SQL table but it did not put anything in the DoctorBean.java file telling it that the primary key was auto-incremented.
    Using the JSP files, I can retreive data out of the database fine so I know the connection and drivers are set up properly.
    Here is the error:
    09:16:46,815 WARN  [ServiceController] Problem starting service jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(Unknown Source)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:197)
        at org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:277)
        at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:284)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:511)
        at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:405)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at org.jboss.mx.loading.LoaderRepositoryClassLoader.loadClass(LoaderRepositoryClassLoader.java:90)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:89)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityCommandMetaData.<init>(JDBCEntityCommandMetaData.java:73)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCEntityMetaData.<init>(JDBCEntityMetaData.java:952)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCApplicationMetaData.<init>(JDBCApplicationMetaData.java:378)
        at org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCXmlFileLoader.load(JDBCXmlFileLoader.java:89)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadJDBCEntityMetaData(JDBCStoreManager.java:736)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.initStoreManager(JDBCStoreManager.java:424)
        at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.java:368)
        at org.jboss.ejb.plugins.CMPPersistenceManager.start(CMPPersistenceManager.java:172)
        at org.jboss.ejb.EjbModule.startService(EjbModule.java:414)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy25.start(Unknown Source)
        at org.jboss.ejb.EJBDeployer.start(EJBDeployer.java:662)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
        at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
        at org.jboss.ws.integration.jboss.DeployerInterceptor.start(DeployerInterceptor.java:92)
        at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
        at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy26.start(Unknown Source)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at sun.reflect.GeneratedMethodAccessor54.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy8.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy4.start(Unknown Source)
        at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy5.deploy(Unknown Source)
        at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
        at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
        at org.jboss.Main.boot(Main.java:200)
        at org.jboss.Main$1.run(Main.java:490)
        at java.lang.Thread.run(Unknown Source)
    09:16:46,862 INFO  [EJBDeployer] Deployed: file:/C:/java/jboss-4.0.5.GA/server/default/deploy/MedicalEJB.jar
    09:16:46,987 INFO  [TomcatDeployer] deploy, ctxPath=/MedicalWeb, warUrl=.../tmp/deploy/tmp63256MedicalWeb-exp.war/
    09:16:47,315 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
    09:16:47,503 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
    --- MBeans waiting for other MBeans ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:service=EjbModule,module=MedicalEJB.jar
      State: FAILED
      Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: 01Simple Doctor table:
    CREATE TABLE [dbo].[Doctors](
        [DoctorId] [int] IDENTITY(1,1) NOT NULL,
        [firstName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [lastName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    CONSTRAINT [PK_Doctors] PRIMARY KEY CLUSTERED
        [DoctorId] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]Most of DoctorBean.java was createded automatically with xdoclet, I created these items manually but with no success:
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"DoctorBean.java:
    package com.bdintegrations.MedicalApp.EJB;
    import java.rmi.RemoteException;
    import javax.ejb.EJBException;
    import javax.ejb.EntityContext;
    import javax.ejb.RemoveException;
    * <!-- begin-xdoclet-definition -->
    * @ejb.bean name="Doctor"
    *    jndi-name="Doctor"
    *    type="CMP"
    *  primkey-field="doctorid"
    *  schema="DoctorSCHEMA"
    *  cmp-version="2.x"
    *  @ejb.persistence
    *   table-name="dbo.Doctors"
    * @ejb.finder
    *    query="SELECT OBJECT(a) FROM DoctorSCHEMA as a" 
    *    signature="java.util.Collection findAll()" 
    * @ejb.pk
    *  class="java.lang.Object"
    *  generate="false"
    * @jboss.entity-command
    * name="mssql-get-generated-keys"
    * @jboss.unknown-pk
    * class="java.lang.Integer"
    * column-name="doctorid"
    * field-name="doctorid"
    * jdbc-type="INTEGER"
    * sql-type="int"
    * auto-increment="true"
    * @jboss.persistence
    * datasource="java:/MSSQLDS"
    * datasource-mapping="MS SQLSERVER2005"
    * table-name="dbo.Doctors"
    * create-table="false" remove-table="false"
    * alter-table="false"
    * <!-- end-xdoclet-definition -->
    * @generated
    public abstract class DoctorBean implements javax.ejb.EntityBean {
         * <!-- begin-user-doc -->
         * The  ejbCreate method.
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.create-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public java.lang.Object ejbCreate(String firstName, String lastName) throws javax.ejb.CreateException {
            setFirstname(firstName);
            setLastname(lastName);
            return null;
            // end-user-code
         * <!-- begin-user-doc -->
         * The container invokes this method immediately after it calls ejbCreate.
         * <!-- end-user-doc -->
         * @generated
        public void ejbPostCreate() throws javax.ejb.CreateException {
            // begin-user-code
            // end-user-code
         * <!-- begin-user-doc -->
         * CMP Field doctorid
         * Returns the doctorid
         * @return the doctorid
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="DoctorId"
         *     jdbc-type="INTEGER"
         *     sql-type="int identity"
         *     read-only="false"
         * @ejb.pk-field
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.Integer getDoctorid();
         * <!-- begin-user-doc -->
         * Sets the doctorid
         * @param java.lang.Integer the new doctorid value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setDoctorid(java.lang.Integer doctorid);
         * <!-- begin-user-doc -->
         * CMP Field firstname
         * Returns the firstname
         * @return the firstname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="firstName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getFirstname();
         * <!-- begin-user-doc -->
         * Sets the firstname
         * @param java.lang.String the new firstname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setFirstname(java.lang.String firstname);
         * <!-- begin-user-doc -->
         * CMP Field lastname
         * Returns the lastname
         * @return the lastname
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.persistent-field
         * @ejb.persistence
         *    column-name="lastName"
         *     jdbc-type="VARCHAR"
         *     sql-type="varchar"
         *     read-only="false"
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract java.lang.String getLastname();
         * <!-- begin-user-doc -->
         * Sets the lastname
         * @param java.lang.String the new lastname value
         * <!-- end-user-doc -->
         * <!-- begin-xdoclet-definition -->
         * @ejb.interface-method
         * <!-- end-xdoclet-definition -->
         * @generated
        public abstract void setLastname(java.lang.String lastname);
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbActivate()
        public void ejbActivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbLoad()
        public void ejbLoad() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbPassivate()
        public void ejbPassivate() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbRemove()
        public void ejbRemove() throws RemoveException, EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#ejbStore()
        public void ejbStore() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
        public void setEntityContext(EntityContext arg0) throws EJBException,
                RemoteException {
            // TODO Auto-generated method stub
        /* (non-Javadoc)
         * @see javax.ejb.EntityBean#unsetEntityContext()
        public void unsetEntityContext() throws EJBException, RemoteException {
            // TODO Auto-generated method stub
        public DoctorBean() {
            // TODO Auto-generated constructor stub
    }JSP client page snippet:
    <%
    DoctorHome home = DoctorUtil.getHome();
    Doctor doctor = home.create("Jon","Smith");
    %>
    <%=doctor.getDoctorid() %>thanks

    Nevermind.. no one bothered to inform the developer that the path to the collection AND the path to the directory that the collection is for are different on this other server.
    Fixed.

  • How can i create an auto increment column

    Hello Everyone
    We are working on an EAM package which has an auto number facility but that is not meeting our requirement because some 10s and 100s of numbers keep on jumping based on the number of records the child table has.Means every record in my parent table will have some child records in another table which we call it a child table.The number of numbers that will be jumped each time will depend on the number of child records it has. Now we want to create a new column and generate a sequential unique number in my parent table with out linking it to its child table and use this number as a reference number. And we cant do that through our package customization. Can any one guide us if we can meet our requirement through oracle triggers or so.
    Thanks and Regards

    Hi,
    For "Auto-Increment" functionality - you can use a combination of a sequence and a trigger like so:
    create table roles ( role_id INT
                       , role_name VARCHAR2(30) NOT NULL
                       , creation_date DATE DEFAULT SYSDATE NOT NULL
                       , role_description VARCHAR2(255)
                       , CONSTRAINT roles_pk PRIMARY KEY (role_id)
                       , CONSTRAINT roles_uk1 UNIQUE (role_name)
    create sequence role_id_seq
    start with 1
    increment by 1
    nocache;
    CREATE OR REPLACE TRIGGER roles_pk_trig
    BEFORE
    insert on roles
    for each row
    begin
    IF :new.role_id IS NULL THEN
       SELECT role_id_seq.NEXTVAL
       INTO :new.role_id
       FROM dual;
    END IF;
    end;
    /Now any insert which leaves the "ROLE_ID" column NULL will have an auto-incremented value put in for that column. This is similar to an "Autonumber" column in Access.
    Hope this helps...
    Take care.

  • Auto-increment column increase performance in this case ?

    hi.
    i have the following facts to construct a set of tables.
    1. A Lecturer has an ID, Name and Date Joined
    2. A Classroom has an ID, Number Of Students
    3. A Lecturer can Teach in Many Classes
    4. A Class Can be lectured by Many Lecturers
    5. Each Lecture Date should be Stored in the DB.
    considering those facts, the following schema can be derived
    Lecturer
    (Lecturer_ID (PK), Lecturer_name, Date_Joined)
    Classroom
    (Classroom_ID (PK), NumOfStudents)
    Class_Lectures
    (Classroom_ID, Lecturer_ID (Composte PK), LectureDate)
    this is the normal practice we do.
    but what if the 3rd Table is constructed as follows ?
    Class_Lectures
    (LectureSeriesID (Auto-Increment, PK), Classroom_ID, Lecturer_ID (Composte Unique Key), LectureDate)
    if the 3rd Table is created as above, will there be any performance differences ? will the performance improve or get reduced ? any advantages / disadvantages of having that structure ?
    please do advise my any further best practices as well.
    Thanks and Regards

    http://technet.oracle.com:89/ubb/Forum88/HTML/000944.html
    null

  • Not authorised to have auto increment trigger on server

    Hello all. I need a few triggers set up, I have no problems setting up sequences and "before insert" triggers on my home PC setup but on the live server where I study I do not have the authority.
    I got around this before by using Forms so I set the trigger at Form level.
    I am developing a DB system that will at some stage in the future use Forms, but for now it will use HTML forms via a web browser.
    I need to have the primary key for user accessible tables to be auto incremented (on the server where I study), but how can get around the authority issue ??
    Any ideas are extremely welcome !!

    Hello all - yeah I am on a course. I too have no idea why they will not allow the students to create triggers at table level.
    The 1st system I developed at home I had auto incremented primary keys. It was using Oracle Forms as the front end. Because I am the admin on my home setup I didn't have any problems.
    When I went to the course site to implement exactly what I had at home (which worked 100% properly) inserting data via the forms was not working. I had no idea why. the lecturer guy took a look at my code and told me its because of the trigger, I do not have authority to create triggers on the server.
    "create or replace trigger cust_trg
    before insert on customer
    for each row
    begin
    select cust_seq.nextval into :new.cust_id
    from dual;
    end;"
    The above code works fine on my home PC. I used Pre Insert triggers on the block on the Form instead to get around the problem (I presumed it was because they wanted us to learn Forms more thoroughly).
    This next project does not involve forms but they will not change my access rights so I don't have a clue as to how to get an auto incremented primary key whilst using a HTML form.
    Kevin

  • CMP with auto-increment primary key.Please help

    Hi all,
    I new with EJB technology so please bear with me.
    Env: 2k Server, SQL 2k Server
    Sun One(Forte EE) to develop and deploy CMP
    I got the servlet to load the data from CMP's business mehods
    is fine. Calling the findPrimaryKey is OK too. Even when I try to insert the row into DB is OK. At this time I make key PK is int AND NOT
    AUTO INCREMENT everything is OK. In the ejbCreate method
    I called setPK, setName ...It's fine.
    The problem comes when I try to make the PK(still int) to be auto-increment field.In ejbCreate not call setPK because of in SunOne IDE, under the J2EE RI tab of EJB Module property, the Auto generate SQL I set to false so that I can
    modify the SQL statement under SQL Deployment.createRow not taking the PK. I thought that will do it but it doesnot like it at all (I got Exception with transaction rollback)I just want to insert a single row with ID and name that's all.
    Then I changed the SQL statment take PK and changed the Auto Generate SQL to True and in ejbCreate the PK as one of the args and called setPK this time with null object. It doesn't like neither.(Exception Cannot set the primary key with null. That is reasonable.)
    I thought using EJB fast and clean technique would help developer to develop application with easiness.
    So I realy stuck with this, I wonder ejb 2.0 support for auto increment at all because I would like to take advantage of the auto increment feature of the DB without writing the PrimaryKeySequence generator at all.
    Am I missing something with this? May be just config thing to tell
    that my PK is auto-increment field so that when the ejbCreate called it knows not taking the PK or even not asking to call setPK in ejbCreate.
    Any help would appreciated.

    Check out this thread, there's a bunch of good info:
    http://www.theserverside.com/patterns/thread.jsp?thread_id=4976

  • How to get auto-increment value after insert on ACCESS db?

    When you insert a new record to a table with an auto-incrementing key, how do you find the value for the row you just inserted? This works differently with different databases. I know how it's done on ORACLE and mySql.
    How does it work with ACCESS through ODBC? How about MSSQL?

    I have discovered there's a LAST aggregate function which when I've tested it gets the just inserted auto-increment, but I'm not sure if it's reliable. You have to do:
    SELECT LAST(index-field) FROM table
    That ought to be faster than MAX, which I've noticed some people use. Persumable LAST will get the value from the last row in the table's natural order.
    In fact an auto-increment field has no business filling in missing slots since the main point is a a foreign key in other tables and a foreign key pointing to a deleted table row ought to be invalidated, not point to some unrelated successor record.
    I could use a separate table as a source of counters, of course, though that's one more call. In either case I'm worried about thread safety. In Oracle there are special sequence objects for this purpose which are incremented and read atomically. I'm not sure if the access driver transaction handling works adequately.
    Perhaps the safest approach might be to use a separate sequencer table and Java sychronisation to serialise access to each row in the sequencer table (assuming all the access is from the same app).

  • Error & Missing explanation in docs regarding Auto Increment / Identity

    Hi Data Modeler-Team, Hi fellow readers,
    could you please explain the meaning of option
    "Column Properties" - "General" - "Identity" (next to "Auto Increment"), as I don't see a logical difference between those two.
    Also, the meaning of these fields is left out in the docs under
    http://docs.oracle.com/cd/E18464_01/doc.30/e15802.pdf "3.8 Column Properties" - "General" (page 75)
    Thanks,
    Blama
    (WinXP, Version 3.0.0.665)
    Edited by: bl**** on 30.12.2011 15:40

    Hi Philip, Hi David,
    thank you for your answers.
    I saw now that "identity" is removed for one column if I assign "identity" to another column and that I can have many auto-increments within one table.
    But what does "identity" mean exactly? I don't see a difference in the displayed relational model and also don't see a difference in the created DDL.
    Isn't "identity" from the meaning the same as a Primary Key?
    Thanks,
    Blama

Maybe you are looking for

  • IPad 2 to Mac

    Hey guys, ive got a issue with getting things from my iPad 2 to my Macbook, I could not find a way how does it work So if i can help, it would be great

  • Can we settle refurbishment order periodically

    Hi All our client want to settle refurbishment order periodically to material. In standard SAP will allow this after TECO. They r taking more time to complete these orders and costs are setteled in Orders and not reflecting in monthly cost balance sh

  • Aperture 3, lens corrections and Micro 4/3rds?

    Does anyone know if Aperture 3 supports the lens corrections that are part of the Micro 4/3rds spec? Presumably this is what was holding up support from being added but can anyone confirm or deny whether they actually do support it now?

  • Having problems distributing my form

    Hi, I can create a form just fine but when I come to distribute it, I get as far as choosing my recipients, clicking send and then the 'encountered a problem and need to close' error message pops up. This is the same no matter which distribution opti

  • Loop through files locating specific data sets

    Hi there, I have been given the wonderful task of developing a setup which needs to do the following using JCAPS: - open and read through various flat files in a folder. These flat files have random data sets in them, where a line starting with 01, m