Hi Dave...

Thats what I thought. When I try that, I don't ever seem to catch a 
DuplicateKeyException. Rather, I catch a CreateException. Here is the code 
I wrote and the log excerpt. You can se the exception thrown by Hypersonic 
when the key is a dupe and then you can see the CreateException caught by 
my code. There is no evidence that I ever caught the DuplicateKeyException.

Am I doing somethign wrong?

Thanks again... Your a fountain of information and a huge help!

Jim


try
{
        uar = home.create(regUar, lidr, cr);
}
catch(DuplicateKeyException e)
{
        tr.print("DuplicateKeyException while creating UAR record: " + 
e.getMessage());
        throw new RnDuplicateUarException("The UAR ID " + 
regUar.getTag().toString() + " already                                  exists");
}
catch(CreateException e)
{
        tr.print("Create Exception while creating UAR record: " + e.getMessage());
        return null;
}
catch(RemoteException e)
{
        tr.print("RE:System/communication error: " + e.getMessage());
        return null;
}


[CreateNewUARSlsb] CreateNewUarBean Sat Mar 03 19:33:25 EST 2001 Calling 
createUarEb()
[CreateNewUARSlsb] CreateNewUarBean Sat Mar 03 19:33:25 EST 2001 method 
createUarEb() entered
[UarEntity] UarEJB Sat Mar 03 19:33:26 EST 2001 ejbCreate() entered
[UarEntity] UarEJB Sat Mar 03 19:33:26 EST 2001 Primary key set to: 
UAR:JARCHER:S
[UarEntity] UarEJB Sat Mar 03 19:33:26 EST 2001 ejbCreate() exited
[UarEntity] java.sql.SQLException: Violation of unique index in statement 
[insert into UarEntity (uarTagName, personal, endUser, entityName, 
accountName, addr1, addr2, addr3, city, state, postalCode, countryCode, 
phone, fax, dateAdded, dateLastMod) values ('UAR:JARCHER:S', TRUE, TRUE, 
'Processing Innovations, LLC', 'JARCHER', '10 Crestview Drive', 'Address 
Line 2', 'Address Line 3', 'Greenville', 'RI', '02828', 'USA', 
'401-949-4768', '401-949-5814', '2001-03-03', '2001-03-03')]
[UarEntity]     at org.hsql.Trace.getError(Trace.java:124)
[UarEntity]     at org.hsql.Result.<init>(Result.java:70)
[UarEntity]     at org.hsql.jdbcConnection.executeHSQL(jdbcConnection.java:644)
[UarEntity]     at org.hsql.jdbcConnection.execute(jdbcConnection.java:540)
[UarEntity]     at org.hsql.jdbcStatement.fetchResult(jdbcStatement.java:499)
[UarEntity]     at org.hsql.jdbcStatement.executeUpdate(jdbcStatement.java:52)
[UarEntity]     at 
org.hsql.jdbcPreparedStatement.executeUpdate(jdbcPreparedStatement.java:114)
[UarEntity]     at 
org.opentools.minerva.jdbc.PreparedStatementInPool.executeUpdate(PreparedSt
atementInPool.java:82)
[UarEntity]     at com.regtek.eb20.ImplUarEJB.insert(ImplUarEJB.java:803)
[UarEntity]     at com.regtek.eb20.ImplUarEJB.ejbCreate(ImplUarEJB.java:217)
[UarEntity]     at java.lang.reflect.Method.invoke(Native Method)
[UarEntity]     at 
org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceMana
ger.java:121)
[UarEntity]     at 
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
[UarEntity]     at java.lang.reflect.Method.invoke(Native Method)
[UarEntity]     at 
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContain
er.java:639)
[UarEntity]     at 
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySyn
chronizationInterceptor.java:160)
[UarEntity]     at 
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceIn
terceptor.java:87)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT
.java:264)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
[UarEntity]     at 
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.ja
va:119)
[UarEntity]     at 
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
[UarEntity]     at 
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:316)
[UarEntity]     at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPConta
inerInvoker.java:421)
[UarEntity]     at 
org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:198)
[UarEntity]     at $Proxy21.create(Unknown Source)
[UarEntity]     at 
com.regtek.slsb.CreateNewUARBean.createUarEb(CreateNewUARBean.java:285)
[UarEntity]     at 
com.regtek.slsb.CreateNewUARBean.makeNew(CreateNewUARBean.java:86)
[UarEntity]     at java.lang.reflect.Method.invoke(Native Method)
[UarEntity]     at 
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Statele
ssSessionContainer.java:472)
[UarEntity]     at 
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessS
essionInstanceInterceptor.java:87)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT
.java:459)
[UarEntity]     at 
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
[UarEntity]     at 
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:1
37)
[UarEntity]     at 
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
[UarEntity]     at 
org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.ja
va:271)
[UarEntity]     at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainer
Invoker.java:381)
[UarEntity]     at 
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainer
Invoker.java:452)
[UarEntity]     at 
org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(Stateles
sSessionProxy.java:152)
[UarEntity]     at $Proxy18.makeNew(Unknown Source)
[UarEntity]     at 
com.regtek.protocol_servlets.MakeUAR.doPost(MakeUAR.java:137)
[UarEntity]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[UarEntity]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[UarEntity]     at 
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
[UarEntity]     at org.apache.tomcat.core.Handler.service(Handler.java:286)
[UarEntity]     at 
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
[UarEntity]     at 
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:7
97)
[UarEntity]     at 
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
[UarEntity]     at 
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Http
ConnectionHandler.java:210)
[UarEntity]     at 
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
[UarEntity]     at 
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
[UarEntity]     at java.lang.Thread.run(Unknown Source)
[CreateNewUARSlsb] CreateNewUarBean Sat Mar 03 19:33:26 EST 2001 Create 
Exception while creating UAR record: null
[CreateNewUARSlsb] CreateNewUarBean Sat Mar 03 19:33:26 EST 2001 Back from 
createUarEb()






--On Saturday, March 03, 2001 8:16 AM -0600 David Castro Diephouse 
<[EMAIL PROTECTED]> wrote:

> Jim - javax.ejb.DuplicateKeyException is defined by spec, just create and
> check for that
>
> Jim Archer wrote:
>
>> Hi All...
>>
>> I have what must be a fairly common problem and I was wondering if
>> someone could suggest what they think the preferred solution might be.
>>
>> I need to create an EB for a user and I have set the userid up as a
>> primary jey. Of course, the user ID must be unique. I'm wondering what
>> the best way to detect that a new user has picked an unavailable user ID.
>>
>> First, I could just try to create the EB and catch a create exception.
>> The downside to this seems to be that if I get a create exception I
>> don't know for sure it was created sue to a non-unique key field without
>> looking at the message text that might vary accross servers. So it seems
>> that I can only know that there was some problem.
>>
>> The next option is to use the finder for primary key and see if I get a
>> record back. This would answer the question but seems like extra overhead
>> to introduce. Also, it would result in a FinderException when the userID
>> is unique and I don't know if that will roll back the transaction I'm in
>> or not. Of course, I have to check for existance and add the new one in
>> the same transaction.
>>
>> Is there a third option? I would appreciate any suggestions!
>>
>> Thanks lots!
>>
>> Jim
>>
>> ********************************************
>> I shall be telling this with a sigh
>> Somewhere ages and ages hence:
>> Two roads diverged in a wood, and I -
>> I took the one less traveled by,
>> And that has made all the difference.
>>
>> - Robert Frost, 1916
>>
>> --
>> --------------------------------------------------------------
>> To subscribe:        [EMAIL PROTECTED]
>> To unsubscribe:      [EMAIL PROTECTED]



********************************************
I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I -
I took the one less traveled by,
And that has made all the difference.

- Robert Frost, 1916



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]

Reply via email to