I am creating a database connection from a datsource in jboss for sqlServer and then using preparedtaement execute a batch which fails with some unique contraint errors. This returns an instance of SQLServerException instead of BatchUpdateException.

My java code does a exception handling on BatchUpdateException.

This works fine on oracle but fails in SqlServer.

But on SQL Server if I get the connection using normal driverManager it work fine.
Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://my-server:1433;User=user;Password=passwod");

I used a similar datsource configuration file in jboss for getting a datsource connection

<?xml version="1.0" encoding="UTF-8"?>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver </driver-class>
<!-- This will be run before a managed connection is removed from the pool for use by a client-->
<check-valid-connection-sql>select 1</check-valid-connection-sql>
<!-- The minimum connections in a pool/sub-pool. Pools are lazily constructed on first use -->
<!-- The maximum connections in a pool/sub-pool -->