10 Replies Latest reply on Dec 20, 2005 3:52 PM by 666705

    SQLException not thrown with connection from data source

    666705
      App Server: WLS 8.1 SP 4
      DB: MS SQL Server 2000
      JDBC Drivers: inet Merlia, BEA SQLServerDriver

      When a JDBC operation violating an integrity constraint (e.g. unique key constraint, referential constraint) is executed from a Session Bean, a NullPointerException is thrown instead of a SQLException containing the "real" cause of the problem. This prevent us from catching the exception and giving the user a more appropriate explanation of the error.

      This only occurs when the connection is acquired from a (correctly configured) data source in WLS. When the connection is obtained in the "plain" way [i.e. Class.forName(...); DriverManager.getConnection()] the right exception is thrown.

      The funny thing is that if I turn on jdbc log, the SQLException appears in the log, but never appears in the server console and we can't catch it neither. As said before a NullPointerException is thrown. Both drivers mentioned above, same error.

      Any help on this will be really appreciated.
      TIA,
      Martin
        • 1. Re: SQLException not thrown with connection from data source
          3004
          Martin Chaia wrote:

          App Server: WLS 8.1 SP 4
          DB: MS SQL Server 2000
          JDBC Drivers: inet Merlia, BEA SQLServerDriver

          When a JDBC operation violating an integrity constraint
          (e.g. unique key constraint, referential constraint) is
          executed from a Session Bean, a NullPointerException is
          thrown instead of a SQLException containing the "real"
          cause of the problem. This prevent us from catching the
          exception and giving the user a more appropriate explanation of the error.

          This only occurs when the connection is acquired from a
          (correctly configured) data source in WLS. When the
          connection is obtained in the "plain" way [i.e. Class.forName(...); DriverManager.getConnection()] the right exception is thrown.

          The funny thing is that if I turn on jdbc log, the SQLException appears in the log, but never appears in the server console and we can't catch it neither. As said before a NullPointerException is thrown. Both drivers mentioned above, same error.

          Any help on this will be really appreciated.
          TIA,
          Martin
          Ok, interesting. Please show me the full stacktrace of the SQLException in the log.
          I will find out why it never gets to you.
          • 2. Re: SQLException not thrown with connection from data source
            666705
            Thank you very much for your answer Joe. Here they go complete stack traces, one for each JDBC driver, extracted from jdbc log. Note that we are using Hibernate but I can assure you that it has nothing to do with the issue. I paste a third stack trace that is what I get from the WLS console.

            ***** With BEA SQLServerDriver *****

            SQLException: SQLState(23000) vendor code(2627)
            java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Violation of UNIQUE KEY constraint 'UQ__BROKERAGE_HOUSE__40064DAA'. Cannot insert duplicate key in object 'BROKERAGE_HOUSE'.
                 at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
                 at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
                 at weblogic.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
                 at weblogic.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
                 at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
                 at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                 at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                 at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                 at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                 at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                 at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                 at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                 at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                 at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                 at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                 at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
            SQLException: SQLState(HY000) vendor code(3621)
            java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]The statement has been terminated.
                 at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
                 at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processInfoToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
                 at weblogic.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
                 at weblogic.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
                 at weblogic.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
                 at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
                 at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
                 at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                 at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                 at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                 at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                 at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                 at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                 at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                 at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                 at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                 at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                 at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

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

            ***** With i-net MERLIA-xs 6.03 *****

            SQLException: SQLState(23000) vendor code(2627)
            com.inet.tds.SQLException: Msg 2627, Level 14, State 2, Line 1, Sqlstate 23000
            [CS]Violation of UNIQUE KEY constraint 'UQ__BROKERAGE_HOUSE__40064DAA'. Cannot insert duplicate key in object 'BROKERAGE_HOUSE'.
                 at com.inet.tds.a.a(Unknown Source)
                 at com.inet.tds.a.a(Unknown Source)
                 at com.inet.tds.b.try(Unknown Source)
                 at com.inet.tds.b.executeUpdate(Unknown Source)
                 at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                 at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                 at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                 at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                 at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                 at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                 at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                 at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                 at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                 at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                 at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                 at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                 at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                 at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
            SQLWarning: reason([CS]The statement has been terminated.) SQLstate(01000) vendor code(3621)

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

            ***** BEA WLS Console *****

            java.lang.NullPointerException
                 at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:153)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                 at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                 at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                 at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                 at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                 at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                 at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                 at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                 at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                 at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                 at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                 at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                 at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
            • 3. Re: SQLException not thrown with connection from data source
              3004
              Hi.
              And the code at
              net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
              Never gets a SQLException? Or does it catch exceptions? I have looked at
              our wrapper code, and I can't believe we're blocking/intercepting SQLExceptions
              from being delivered to hibernate, or whoever else is using our stuff.
              I'd also want to look at
              com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:153) to
              solve the NullPointer problem.
              Joe


              Martin Chaia wrote:

              Thank you very much for your answer Joe. Here they go complete stack traces, one for each JDBC driver, extracted from jdbc log. Note that we are using Hibernate but I can assure you that it has nothing to do with the issue. I paste a third stack trace that is what I get from the WLS console.

              ***** With BEA SQLServerDriver *****

              SQLException: SQLState(23000) vendor code(2627)
              java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]Violation of UNIQUE KEY constraint 'UQ__BROKERAGE_HOUSE__40064DAA'. Cannot insert duplicate key in object 'BROKERAGE_HOUSE'.
                   at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
                   at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
                   at weblogic.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
                   at weblogic.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
                   at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
                   at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                   at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                   at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                   at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                   at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                   at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                   at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                   at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                   at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
              SQLException: SQLState(HY000) vendor code(3621)
              java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]The statement has been terminated.
                   at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
                   at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processInfoToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
                   at weblogic.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
                   at weblogic.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
                   at weblogic.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
                   at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
                   at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
                   at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                   at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                   at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                   at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                   at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                   at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                   at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                   at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                   at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

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

              ***** With i-net MERLIA-xs 6.03 *****

              SQLException: SQLState(23000) vendor code(2627)
              com.inet.tds.SQLException: Msg 2627, Level 14, State 2, Line 1, Sqlstate 23000
              [CS]Violation of UNIQUE KEY constraint 'UQ__BROKERAGE_HOUSE__40064DAA'. Cannot insert duplicate key in object 'BROKERAGE_HOUSE'.
                   at com.inet.tds.a.a(Unknown Source)
                   at com.inet.tds.a.a(Unknown Source)
                   at com.inet.tds.b.try(Unknown Source)
                   at com.inet.tds.b.executeUpdate(Unknown Source)
                   at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:528)
                   at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
                   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
                   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
                   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
                   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.basicSave(BrokerageHouseMaintenanceBean.java:63)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithoutValidateWithSemanticCheck(AbstractCrudBean.java:230)
                   at com.lumina.j2ee.crud.AbstractCrudBean.saveWithSemanticCheck(AbstractCrudBean.java:215)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:207)
                   at com.lumina.j2ee.crud.AbstractCrudBean$1.block(AbstractCrudBean.java:52)
                   at com.lumina.persistence.SessionCommand.execute(SessionCommand.java:34)
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:136)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                   at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                   at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                   at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                   at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                   at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                   at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
              SQLWarning: reason([CS]The statement has been terminated.) SQLstate(01000) vendor code(3621)

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

              ***** BEA WLS Console *****

              java.lang.NullPointerException
                   at com.lumina.j2ee.crud.AbstractCrudBean.save(AbstractCrudBean.java:153)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenanceBean.save(BrokerageHouseMaintenanceBean.java:39)
                   at com.lor.marketdata.ejb.impl.BrokerageHouseMaintenance_a8x9f4_ELOImpl.save(BrokerageHouseMaintenance_a8x9f4_ELOImpl.java:46)
                   at com.lor.marketdata.ejb.impl.MarketDataFacadeBean.saveBrokerageHouse(MarketDataFacadeBean.java:282)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl.saveBrokerageHouse(MarketDataFacade_1bsk9c_EOImpl.java:424)
                   at com.lor.marketdata.ejb.impl.MarketDataFacade_1bsk9c_EOImpl_WLSkel.invoke(Unknown Source)
                   at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                   at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                   at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                   at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                   at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                   at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                   at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
              • 4. Re: SQLException not thrown with connection from data source
                666705
                OK Joe. I've completely isolated the problem. I got rid of Hibernate from the middle and I came up with a very simple example that allows me to reproduce the error.
                It consists of a session bean executing a jdbc prepared statement (an insert). A remote, stand-alone client invokes this session bean. Of course, the row being inserted is violating a unique key constraint.

                This is the table creation script:

                CREATE TABLE OFFICE (
                     OID numeric(19, 0) IDENTITY (1, 1) NOT NULL ,
                     MODIFICATION_TIMESTAMP datetime NOT NULL ,
                     CREATION_TIMESTAMP datetime NOT NULL ,
                     CREATION_USER_ID varchar(20) NOT NULL ,
                     MODIFICATION_USER_ID varchar(20) NOT NULL ,
                     MODIFICATION_IP_ADDRESS varchar(20) NOT NULL ,
                     CREATION_IP_ADDRESS varchar(20) NOT NULL ,
                     OFICCE_ID varchar(2) NOT NULL ,
                     NAME varchar(30) NULL ,
                     ACTIVE tinyint NOT NULL
                )
                GO

                ALTER TABLE OFFICE ADD
                     PRIMARY KEY (OID),
                     UNIQUE (OFICCE_ID)
                GO

                Note the unique constraint on OFFICE_ID field.
                The following row is already present in the OFFICE table:

                (2, 7/13/2005 11:49:39 AM, 7/13/2005 11:49:39 AM, 'mchaia', 'mchaia', '127.0.0.1', '127.0.0.1', 'UQ', 'Office Name', 1)

                So if I try to insert a new row with OFFICE_ID = 'UQ' there is a unique key constraint violation, right? This is exactly what my code is trying to do.

                Here it goes the session bean code (implementation only, no home/local/remote interfaces). Pay attention to test() method:

                package com.lumina.test.db.ejb;

                import java.rmi.RemoteException;
                import java.sql.Connection;
                import java.sql.DriverManager;
                import java.sql.PreparedStatement;
                import java.sql.Statement;
                import java.sql.Timestamp;

                import javax.ejb.CreateException;
                import javax.ejb.EJBException;
                import javax.ejb.SessionBean;
                import javax.ejb.SessionContext;
                import javax.naming.InitialContext;
                import javax.rmi.PortableRemoteObject;
                import javax.sql.DataSource;

                /**
                * XDoclet-based session bean. The class must be declared
                * public according to the EJB specification.
                *
                * To generate the EJB related files to this EJB:
                *          - Add Standard EJB module to XDoclet project properties
                *          - Customize XDoclet configuration for your appserver
                *          - Run XDoclet
                *
                * Below are the xdoclet-related tags needed for this EJB.
                *
                * @ejb.bean name="TestDuplicateKey"
                * display-name="Name for TestDuplicateKey"
                * description="Description for TestDuplicateKey"
                * jndi-name="ejb/TestDuplicateKey"
                * type="Stateless"
                * view-type="both"
                */
                public class TestDuplicateKey implements SessionBean {
                     
                     private static final String URL = "jdbc:inetdae7:64.76.30.171:1433?database=OMAS_DEV";
                     private static final String USER = "omas";
                     private static final String PASSWORD = "omas2004";

                     /** The session context */
                     private SessionContext context;

                     public TestDuplicateKey() {
                          super();
                          // TODO Auto-generated constructor stub
                     }

                     public void ejbActivate() throws EJBException, RemoteException {
                          // TODO Auto-generated method stub

                     }

                     public void ejbPassivate() throws EJBException, RemoteException {
                          // TODO Auto-generated method stub

                     }

                     public void ejbRemove() throws EJBException, RemoteException {
                          // TODO Auto-generated method stub

                     }

                     /**
                     * Set the associated session context. The container calls this method
                     * after the instance creation.
                     *
                     * The enterprise bean instance should store the reference to the context
                     * object in an instance variable.
                     *
                     * This method is called with no transaction context.
                     *
                     * @throws EJBException Thrown if method fails due to system-level error.
                     */
                     public void setSessionContext(SessionContext newContext) throws EJBException {
                          context = newContext;
                     }

                     /**
                     * An ejbCreate method as required by the EJB specification.
                     *
                     * The container calls the instance?s <code>ejbCreate</code> method whose
                     * signature matches the signature of the <code>create</code> method invoked
                     * by the client. The input parameters sent from the client are passed to
                     * the <code>ejbCreate</code> method. Each session bean class must have at
                     * least one <code>ejbCreate</code> method. The number and signatures
                     * of a session bean?s <code>create</code> methods are specific to each
                     * session bean class.
                     *
                     * @throws CreateException Thrown if method fails due to system-level error.
                     *
                     * @ejb.create-method
                     *
                     */
                     public void ejbCreate() throws CreateException {
                          // TODO Add ejbCreate method implementation
                     }

                     /**
                     * An example business method
                     *
                     * @ejb.interface-method view-type = "both"
                     * @ejb.transaction type="Required"
                     *
                     * @throws EJBException Thrown if method fails due to system-level error.
                     */
                     public void test() {
                          try {
                //               Class.forName("com.inet.tds.PDataSource");
                //               Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
                               
                               Connection conn = this.getDatabaseDataSource("jdbc/MSSQLDS")
                                         .getConnection();
                                         
                               String sqlStr = "insert into OFFICE (MODIFICATION_TIMESTAMP, CREATION_TIMESTAMP, CREATION_USER_ID, MODIFICATION_USER_ID, MODIFICATION_IP_ADDRESS, CREATION_IP_ADDRESS, OFICCE_ID, NAME, ACTIVE) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
                               
                               PreparedStatement pst = conn.prepareStatement(sqlStr, Statement.RETURN_GENERATED_KEYS);
                               
                               pst.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
                               pst.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
                               pst.setString(3, "mchaia");
                               pst.setString(4, "mchaia");
                               pst.setString(5, "127.0.0.1");
                               pst.setString(6, "127.0.0.1");
                               pst.setString(7, "UQ");
                               pst.setString(8, "Office Name");
                               pst.setInt(9, 1);
                               pst.executeUpdate();
                               pst.close();
                               conn.close();
                               
                          } catch (Exception e) {
                               System.out.println(e.getMessage());
                               e.printStackTrace();
                          }
                     }
                     
                     private DataSource getDatabaseDataSource(String dsJndiName) {
                          DataSource ds = null;
                          try {
                               InitialContext ic = new InitialContext();
                               Object objref = ic.lookup(dsJndiName);
                               Object obj = PortableRemoteObject.narrow(objref, DataSource.class);
                               ds = (DataSource) obj;
                          } catch (Exception e) {
                               e.printStackTrace();
                          }
                          return ds;
                     }
                }

                Yeah, yeah, I know. 'Statement.RETURN_GENERATED_KEYS' constant only works for JDBC 3.0 drivers. OK, Merlia & WLS provided drivers are JDBC 3.0 compliant.
                Note that the connection is acquired from a data source. In this case the stack trace at the server console
                is:

                java.lang.NullPointerException
                     at weblogic.jdbc.common.internal.StatementCacheKey.<init>(StatementCacheKey.java:34)
                     at weblogic.jdbc.common.internal.ConnectionEnv.clearStatement(ConnectionEnv.java:1329)
                     at weblogic.jdbc.wrapper.Connection.clearPreparedStatement(Connection.java:179)
                     at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:149)
                     at com.lumina.test.db.ejb.TestDuplicateKey.test(TestDuplicateKey.java:128)
                     at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl.test(TestDuplicateKey_u87kbu_EOImpl.java:45)
                     at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl_WLSkel.invoke(Unknown Source)
                     at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                     at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                     at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                     at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                     at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
                     

                If you comment the line obtaining the connection from a data source and uncomment the two above, the right stack trace is shown:

                [CS]Violation of UNIQUE KEY constraint 'UQ__OFFICE__4CA12EB9'. Cannot insert duplicate key in object 'OFFICE'.
                com.inet.tds.SQLException: Msg 2627, Level 14, State 2, Line 1, Sqlstate 23000
                [CS]Violation of UNIQUE KEY constraint 'UQ__OFFICE__4CA12EB9'. Cannot insert duplicate key in object 'OFFICE'.
                     at com.inet.tds.a.a(Unknown Source)
                     at com.inet.tds.a.a(Unknown Source)
                     at com.inet.tds.b.try(Unknown Source)
                     at com.inet.tds.b.executeUpdate(Unknown Source)
                     at com.lumina.test.db.ejb.TestDuplicateKey.test(TestDuplicateKey.java:129)
                     at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl.test(TestDuplicateKey_u87kbu_EOImpl.java:45)
                     at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl_WLSkel.invoke(Unknown Source)
                     at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                     at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                     at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                     at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                     at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                     at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                     at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                     at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                     at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

                It seams like WLS connection wrappers are eating up the "real" exception when the connection is got from the data source, I don't know...

                The remote client code:

                package com.lumina.test.db;

                import java.util.Hashtable;

                import javax.naming.Context;
                import javax.naming.InitialContext;
                import javax.naming.NamingException;

                import com.lumina.j2ee.servicelocator.ServiceLocator;
                import com.lumina.test.db.interfaces.TestDuplicateKey;
                import com.lumina.test.db.interfaces.TestDuplicateKeyHome;

                public class EJBTester {

                     public static void main(String[] args) {
                          EJBTester tester = new EJBTester();
                          try {
                               TestDuplicateKey ejb = tester.getEJB();
                               ejb.test();
                          } catch (Exception e) {
                               e.printStackTrace();
                          }
                     }

                     private TestDuplicateKey getEJB() throws Exception {
                          ServiceLocator.getInstance().setExternalJNDIContext(this.getInitialContext());
                          TestDuplicateKeyHome h =
                               (TestDuplicateKeyHome) ServiceLocator.getInstance().getRemoteHome("ejb/TestDuplicateKey", TestDuplicateKeyHome.class);

                          return h.create();
                     }     
                     
                     private Context getInitialContext() throws NamingException {
                          Hashtable props = new Hashtable();
                          props.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
                          props.put(Context.PROVIDER_URL, "t3://localhost:7001/");
                          Context ctx = new InitialContext(props);
                          return ctx;
                     }     
                }

                Joe, I really appreciate your time and dedication on this issue.
                Thanks,
                Martin
                • 5. Re: SQLException not thrown with connection from data source
                  3004
                  Martin Chaia wrote:
                  OK Joe. I've completely isolated the problem. I got rid of Hibernate from the middle and I came up with a very simple example that allows me to reproduce the error.
                  It consists of a session bean executing a jdbc prepared statement (an insert). A remote, stand-alone client invokes this session bean. Of course, the row being inserted is violating a unique key constraint.

                  This is the table creation script:

                  CREATE TABLE OFFICE (
                       OID numeric(19, 0) IDENTITY (1, 1) NOT NULL ,
                       MODIFICATION_TIMESTAMP datetime NOT NULL ,
                       CREATION_TIMESTAMP datetime NOT NULL ,
                       CREATION_USER_ID varchar(20) NOT NULL ,
                       MODIFICATION_USER_ID varchar(20) NOT NULL ,
                       MODIFICATION_IP_ADDRESS varchar(20) NOT NULL ,
                       CREATION_IP_ADDRESS varchar(20) NOT NULL ,
                       OFICCE_ID varchar(2) NOT NULL ,
                       NAME varchar(30) NULL ,
                       ACTIVE tinyint NOT NULL
                  )
                  GO

                  ALTER TABLE OFFICE ADD
                       PRIMARY KEY (OID),
                       UNIQUE (OFICCE_ID)
                  GO
                  ...
                  >
                  Joe, I really appreciate your time and dedication on this issue.
                  Thanks,
                  Martin
                  No problem. Here's a slightly altered version of test(). Would you tell me what it prints?


                  public void test()
                  {
                  Connection c = null;
                  try
                  {
                  c = this.getDatabaseDataSource("jdbc/MSSQLDS").getConnection();
                  System.out.println("TEST CALLED. Connection is " + c );


                  String sqlStr = "insert into OFFICE (MODIFICATION_TIMESTAMP, CREATION_TIMESTAMP, CREATION
                  _USER_ID, MODIFICATION_USER_ID, MODIFICATION_IP_ADDRESS, CREATION_IP_ADDRESS, OFICCE_ID, NAME,
                  ACTIVE) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";


                  PreparedStatement pst = c.prepareStatement(sqlStr, Statement.RETURN_GENERATED_KEYS);


                  pst.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
                  pst.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
                  pst.setString(3, "mchaia");
                  pst.setString(4, "mchaia");
                  pst.setString(5, "127.0.0.1");
                  pst.setString(6, "127.0.0.1");
                  pst.setString(7, "UQ");
                  pst.setString(8, "Office Name");
                  pst.setInt(9, 1);
                  int i = pst.executeUpdate();
                  pst.close();
                  c.close();
                  c = null;
                  System.out.println("TEST SUCCEEDS, inserting " + i + " row(s)");
                  }
                  catch (Exception e)
                  {
                  System.out.println("TEST FAILS");
                  e.printStackTrace();
                  }
                  finally
                  {
                  if (c != null) try {c.close();} catch (Exception ignore){}
                  }
                  }
                  • 6. Re: SQLException not thrown with connection from data source
                    666705
                    This is what it prints:

                    TEST CALLED. Connection is weblogic.jdbc.wrapper.JTSConnection_com_inet_tds_a@c
                    java.lang.NullPointerExceptionTEST FAILS

                         at weblogic.jdbc.common.internal.StatementCacheKey.<init>(StatementCacheKey.java:34)
                         at weblogic.jdbc.common.internal.ConnectionEnv.clearStatement(ConnectionEnv.java:1329)
                         at weblogic.jdbc.wrapper.Connection.clearPreparedStatement(Connection.java:179)
                         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:149)
                         at com.lumina.test.db.ejb.TestDuplicateKey.test(TestDuplicateKey.java:122)
                         at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl.test(TestDuplicateKey_u87kbu_EOImpl.java:45)
                         at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl_WLSkel.invoke(Unknown Source)
                         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
                    • 7. Re: SQLException not thrown with connection from data source
                      666705
                      Just in case, the output using the WLS provided driver for MS SQL Server:

                      TEST CALLED. Connection is weblogic.jdbc.wrapper.JTSConnection_weblogic_jdbc_sqlserver_SQLServerConnection@8
                      TEST FAILS
                      java.lang.NullPointerException
                           at weblogic.jdbc.common.internal.StatementCacheKey.<init>(StatementCacheKey.java:34)
                           at weblogic.jdbc.common.internal.ConnectionEnv.clearStatement(ConnectionEnv.java:1329)
                           at weblogic.jdbc.wrapper.Connection.clearPreparedStatement(Connection.java:179)
                           at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:149)
                           at com.lumina.test.db.ejb.TestDuplicateKey.test(TestDuplicateKey.java:122)
                           at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl.test(TestDuplicateKey_u87kbu_EOImpl.java:45)
                           at com.lumina.test.db.ejb.TestDuplicateKey_u87kbu_EOImpl_WLSkel.invoke(Unknown Source)
                           at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
                           at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
                           at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
                           at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
                           at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
                           at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
                           at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
                           at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
                           at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
                      • 8. Re: SQLException not thrown with connection from data source
                        666705
                        Hello:

                        I am having a similar problem, which sounds like it might be related, except in my case I am not getting any exception or warning at all; the update seems to work, and calling getUpdateCount() on my prepared statement returns 1; yet the database wasn't changed, because a foreign key constraint was violated.

                        Executing the same SQL in isql results in the expected error 23000. Perhaps something in the error handler results sometimes in a null pointer exception, and sometimes in no exception?

                        Or, if there is some other option or situation which could result in no exception being returned, I'd appreciate any advice.

                        Thanks very much!
                        Bill
                        • 9. Re: SQLException not thrown with connection from data source
                          666705
                          Hi, I observed the same behaviour with 8.1 SP5, SQL Server?

                          Any resolution????
                          • 10. Re: SQLException not thrown with connection from data source
                            666705
                            It turned out that it was a WLS (8.1 SP 4) bug with MSSQL Server. We became BEA partners and a customized patch was provided to us.

                            Regards,
                            Martin