Category Archives: DB

[Solved] SQLServerException: The definition of object ‘XYZ’ has changed since it was compiled.

JDBC/JPA throws this exception on runtime “com.microsoft.sqlserver.jdbc.SQLServerException: The definition of object ‘XYZ’ has changed since it was compiled.” when call the stored procedure from JAVA code. There can be multiple reason of this issue.

Reason of Exception

This issue occurred with SQL Server or DB objects because these pre-compiled and persist in DB. In your team member or other person opened any tool to modify the object, or opened the Object in any tool in editable mode then SQL Server maintain the state/versioning of changes but not save or executed. Now when your applications run then SQLServer is confused which version of SQL Object need to execute and throw this exception “SQLServerException: The definition of object ‘XYZ’ has changed since it was compiled“.

  • This issue can be occured by parameter sniffing also.
  • or Stored Procedure/ SQL Object opened in editable mode in any tool.

Solutions:

To solve this problem there are following ways:

Solution 1: You can execute the stored procedure/SQL object with sp_recompile from JDBC Java code as below:

call sp_recompile XYZ_SP

Solution 2: You can alter the Stored Procedure as below syntax with WITH RECOMPILE

Syntax:

create procedure <proc_name>
[<parameters]>
WITH RECOMPILE
AS 
<codes>

Solution 3: Recreate the stored procedure/ SQL Object with new name and change the reference of this SQL object new name on all the places.

Recommendation

The Solution 1 and Solution 2 both are having drawback as all the time before executing the stored procedure will re-compile the object. Solution 3 is good in case if you know all the references of uses of stored procedure/ SQL Object in your application/all applications.

Related Posts

Your Feedback Motivate Us

If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.

Happy Learning !!!

[Solved] SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

This issue “SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: “No appropriate protocol (protocol is disabled or cipher suites are inappropriate)” was happening to me when upgrade from jDK 8_271 to JDK_8_341 and MSSQL driver.

Below are the stacktrace of the issue.

Stacktrace

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "No appropriate protocol (protocol is disabled or cipher suites are inappropriate)".
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1412)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1058)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:833)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
	at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
	at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
	at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:120)
	at org.springframework.batch.item.database.AbstractCursorItemReader.initializeConnection(AbstractCursorItemReader.java:422)
	... 30 more
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
	at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171)
	at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:106)
	at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:410)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:389)
	at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1379)
	... 41 more

Solutions

SQL Server JDBC Driver versions are specific to JDK versions. Till JDK_8.271, JDBC driver versions supported as 4.1 however for the latest version JDK_8_341 use the SQL Server JDBC driver 8.4.1.

In my case this issue got resolved by updating the jar file as below:

Old Jar : mssql-jdbc4-2.0.jar

New Jar: mssql-jdbc-8.4.1.jre8.jar

Please refer below the complete SQLServer JDBC driver support matrix specific to Java/JDK versions.

https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver16#java-and-jdbc-specification-support

Please share your comments if this solutions help you to resolve this issue.

Happy Learning !!!

[Solved] SQLServerException: The TCP/IP connection to the host ABCKXYZ356, port 1345 has failed

This is most common exception when connecting with database through Spring boot application. It’s happen because of connection failed to the database.

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host ABCKXYZ356, port 1345 has failed. Error: "ABCKXYZ356. 
Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. 
Make sure that TCP connections to the port are not blocked by a firewall.".    
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2434) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:659) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2546) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2216) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2067) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1204) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:825) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar:na]

Reason of Exception

These are main reason of this Exception:

  • This issue can occurred because of wrong properties configured for database connection.
  • This issue can also occurred if the database is not running.
  • This issue can also occurred if database only allow to access through vpn.

Solutions

These are some most common solution to resolve this issue:

  • Verify the connection properties.
  • Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.
  • Make sure that TCP connections to the port are not blocked by a firewall.
  • Check the vpn connection if DB access allow over the vpn.

Related Posts

Your Feedback Motivate Us

If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.

Happy Learning !!!

[Solved] SQLServerException: Arithmetic overflow error converting float to data type numeric :scientific value

This SQLServerException is common with the applications using the MSSQL database. Once it occurs it generate the below stackTrace.

Exception Stack Trace

com.microsoft.sqlserver.jdbc.SQLServerException: Arithmetic overflow error converting float to data type numeric.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)

Reason of Exception

This issue occurred when your precision and scale argument is set two small for decimal column. For Example: decimal(3,2) or float(3,2) . It will float allow maximum value as 9.99

Basically the first argument (precision) is the max number of digits (in this case 3) and the second argument (scale) is the number of digits to the right of the decimal point, which always takes away from the number of digits you can have to the left of the decimal point. So in this case, 3-2 = 1 digit allowed to the left of the decimal point, which is why allow max value can only be 9.99.

if you will try numeric value more than this size Ex : 10.9 then SQL server will throw exception as “SQLServerException: Arithmetic overflow error converting float to data type numeric” because size is more than the defined precision and scale of decimal point.

Note : This issue can also be occurred when you are trying to insert big values in form of scientific notation Ex: 1.5e100 because it’s precision value is high so throw exception.

Solutions

You can follow any of these processes to resolve this issue:

  • Increase the precision and scale of decimal of your column based on your business requirement.
  • Convert the column type as float value so that accept values as per the set precision and scale.
  • You can also use try_cast also to truncate and change the type of passing value.

Hope these processes resolved this issue. Please share your response in comments.

Happy Learning !!!

[Solved] SQLServerException: Arithmetic overflow error converting float to data type numeric

This SQLServerException is common with the applications using the MSSQL database. Once it occurs it generate the below stackTrace.

Exception Stack Trace

com.microsoft.sqlserver.jdbc.SQLServerException: Arithmetic overflow error converting float to data type numeric.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)

Reason of Exception

This issue occurred when your precision and scale argument is set two small for decimal column. For Example: NUMERIC(3,2) or DECIMAL(3,2) . It will allow maximum value as 9.99

Basically the first argument (precision) is the max number of digits (in this case 3) and the second argument (scale) is the number of digits to the right of the decimal point, which always takes away from the number of digits you can have to the left of the decimal point. So in this case, 3-2 = 1 digit allowed to the left of the decimal point, which is why allow max value can only be 9.99.

if you will try numeric value more than this size Ex : 10.9 then SQL server will throw exception as “SQLServerException: Arithmetic overflow error converting float to data type numeric” because size is more than the defined precision and scale of decimal point.

Solutions

You can follow any of these processes to resolve this issue:

  • Increase the precision and scale of decimal of your column based on your business requirement.
  • Convert the column type as float value so that accept values as per the set precision and scale.

Hope these processes resolved this issue. Please share your response in comments.

Happy Learning !!!

[Solved] SQLServerException: String or binary data would be truncated

This SQLServerException is common with the applications using the MSSQL database. Once it occurs it generate the below stackTrace.

Exception Stack Trace

com.microsoft.sqlserver.jdbc.SQLServerException: String or binary data would be truncated. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696)

Reason of Exception

This exception occurred when you are trying to insert text in a column of type varchar which is more than the size of defined column size then SQL server through this exception “SQLServerException: String or binary data would be truncated“.

Solutions

You can follow any of these processes to resolve this issue:

  • Apply validation for text length on the source frontend/client where you in insert the values. It should be less than or equal to size of column.
  • Apply truncation on text before inserting to the database and it should be less than the column size.
  • Increase the sufficient size of the column based on you requirement to resolve this issue.

Hope these processes resolved this issue. Please share your response in comments.

Happy Learning !!!

LIQUIBASE Spring Boot Properties

LIQUIBASE is a provider of Spring Boot Data for handling database schemas operations. LIQUIBASE is an Open Source tool which keep track of database schema script revisions. It can handle variety of database types and accepts a variety of file formats for defining the database structures.

See Also:

<dependency>
			<groupId>org.liquibase</groupId>
			<artifactId>liquibase-core</artifactId>
</dependency>

After adding LIQUIBASE dependencies in your application it will automatically download and add the required other dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Liquibase Configuration Properties

Spring Boot load these properties in LiquibaseProperties class.

NameDefault ValueDescription
liquibase.change-logclasspath:/db/ changelog/db.
changelog-master.yaml
Change log configuration path.
liquibase.check-change-log-locationtrueCheck the change log location exists.
liquibase.contexts Comma-separated list of runtime contexts to use.
liquibase.default-schema Default database schema.
liquibase.drop-firstfalseDrop the database schema first.
liquibase.enabledtrueEnable liquibase support.
liquibase.labels Comma-separated list of runtime labels to use.
liquibase.parameters.* Change log parameters.
liquibase.password Login password of the database to migrate.
liquibase.rollback-file File to rollback SQL statements will be written when an update is performed.
liquibase.url JDBC url of the database to migrate. Incase not set then use the primary configured data source.
liquibase.user Login user of the database to migrate.
LIQUIBASE Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

Cassandra Spring Boot Properties

Apache Cassandra is a provider of Spring Boot Data for handling NoSQL database operations. Apache Cassandra is a NoSQL distributed database for managing large amounts of data across many servers (clusters) while providing high availability at the cost of decreased consistency. Cassandra high availability is achieved by replicating data to multiple nodes over cluster and allow one or more nodes to go down so that transaction will continue till that point even one server is running.

To use Apache Cassandra in your Spring boot application you have to add this Cassandra starter in your pom.xml .

<dependency>
         <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra</artifactId>
        <version>2.0.0.M7</version>
</dependency>

After adding Cassandra Database starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Cassandra Configuration Properties

Spring Boot load these properties in CassandraProperties class.

NameDefault ValueDescription
spring.data.cassandra.cluster-name Cassandra cluster Name.
spring.data.cassandra.compression Compression supported by the Cassandra binary protocol.
spring.data.cassandra.connect-timeout-millis Socket option: connection time out.
spring.data.cassandra.consistency-level Queries consistency level.
spring.data.cassandra.contact-pointslocalhostComma-separated cluster node addresses.
spring.data.cassandra.fetch-size Queries default fetch size.
spring.data.cassandra.keyspace-name Keyspace name to use.
spring.data.cassandra.load-balancing-policy Class name of the load balancing policy.
spring.data.cassandra.port Port of the Cassandra server.
spring.data.cassandra.password Login password of the server.
spring.data.cassandra.read-timeout-millis Socket option: read time out.
spring.data.cassandra.reconnection-policy Reconnection policy class.
spring.data.cassandra.repositories.enabled Enable Cassandra repositories.
spring.data.cassandra.retry-policy Class name of the retry policy.
spring.data.cassandra.serial-consistency-level Queries serial consistency level.
spring.data.cassandra.schema-actionnoneSchema action to take at startup.
spring.data.cassandra.sslfalseEnable SSL support.
spring.data.cassandra.username Login user of the server.
Cassandra Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

Couchbase Spring Boot Properties

Couchbase is a provider of Spring Boot for handling NoSQL database operations through JSON. Couchbase is NoSQL document oriented distributed database over the cloud or on- premises which perform transactions by JSON and provide unmatched versatility, performance and scalability. To use Couchbase in your Spring boot application you have to add this Couchbase starter in your pom.xml .

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-couchbase</artifactId>
    <version>2.6.3</version>
</dependency>

After adding Couchbase Database starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Data Couchbase Configuration Properties

Spring Boot load these properties in CouchbaseDataProperties class.

NameDefault ValueDescription
spring.data.couchbase.auto-indexfalsecreate views and indexes automatically.
spring.data.couchbase.consistencyread-your-own-writesBy default Consistency to apply on generated queries.
spring.data.couchbase.repositories.enabledtrueEnable Couchbase repositories.
Data Couch Spring Boot properties

Couchbase Configuration Properties

Spring Boot load these properties in CouchbaseProperties class.

NameDefault ValueDescription
spring.couchbase.bootstrap-hosts Couchbase nodes host/IP address to bootstrap from.
spring.couchbase.bucket.namedefaultbucket name connect to.
spring.couchbase.bucket.password bucket password.
spring.couchbase.env.endpoints.key-value1Number of sockets per node for each Key/value service.
spring.couchbase.env.endpoints.query1Number of sockets per node for each Query (N1QL) service.
spring.couchbase.env.endpoints.view1Number of sockets per node for each view service.
spring.couchbase.env.ssl.enabled Enable SSL support. Enabled automatically if a “keyStore” is provided otherwise specified otherwise.
spring.couchbase.env.ssl.key-store Path to JVM key store which holds the certificates.
spring.couchbase.env.ssl.key-store-password Password used to access the key store.
spring.couchbase.env.timeouts.connect5000Bucket connections timeout. (in milliseconds)
spring.couchbase.env.timeouts.key-value2500Blocking operations performed on a key timeout.( in milliseconds)
spring.couchbase.env.timeouts.query7500N1QL query operations timeout.( in milliseconds)
spring.couchbase.env.timeouts.socket-connect1000Socket connect connections timeout.( in milliseconds).
spring.couchbase.env.timeouts.view7500Regular and geospatial view operations timeout. (in milliseconds).
Couchbase Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

MongoDB Spring Boot Properties

MongoDB is a provider of Spring Boot for handling NoSQL database operations. To use MongoDB  in your Spring boot application you have to add this MongoDB starter in your pom.xml .

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>

After adding MongoDB starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Embedded MongoDB Configuration Properties

Spring Boot load these properties in EmbeddedMongoProperties class.

NameDefault ValueDescription
spring.mongodb.embedded.featuresSYNC_DELAYComma-separated features to enable.
spring.mongodb.embedded.storage.database-dir Directory used for data storage.
spring.mongodb.embedded.storage.oplog-size Maximum size of the oplog in megabytes.
spring.mongodb.embedded.storage.repl-set-name Name of the replica set.
spring.mongodb.embedded.version2.6.10Version of Mongo to use.
MongoDB Embedded Spring Boot Properties

MongoDB Configuration Properties

Spring Boot load these properties in MongoProperties class.

NameDefault ValueDescription
spring.data.mongodb.authentication-database Authentication database name.
spring.data.mongodb.databasetestDatabase name.
spring.data.mongodb.field-naming-strategy USe Fully qualified name of the FieldNamingStrategy.
spring.data.mongodb.grid-fs-database GridFS database name.
spring.data.mongodb.hostlocalhostMongo server host.
spring.data.mongodb.password Login password of the mongo server.
spring.data.mongodb.port27017Mongo server port.
spring.data.mongodb.repositories.enabledtrueEnable Mongo repositories.
spring.data.mongodb.urimongodb://localhost/testMongo database URI.host and port are ignored when setting it.
spring.data.mongodb.username Login user of the mongo server.
MongoDB Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Neo4J Spring Boot Properties

Neo4J is a provider of Spring Boot for handling Graphical database.  Neo4J is a graphical datbase where need to represent stored data in graphical relational forms. You can add Neo4J  in your Spring boot application by adding Neo4J starter in your pom.xml (Maven) or build.gradle (Gradle).

Maven

<dependency>
        <groupId>org.neo4j.driver</groupId>
        <artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
        <version>4.3.6.0</version>
</dependency>

Gradle

dependencies {
    compile 'org.neo4j.driver:neo4j-java-driver-spring-boot-starter:4.3.6.0'
}

After adding Neo4J starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Neo4j Configuration Properties

Spring Boot load these properties in Neo4jProperties class.

NameDefault ValueDescription
spring.data.neo4j.compiler Compiler to use.
spring.data.neo4j.embedded.enabledtrueEnable embedded mode when embedded driver is available.
spring.data.neo4j.password Login password of the server.
spring.data.neo4j.repositories.enabledtrueEnable Neo4j repositories.
spring.data.neo4j.session.scopesingletonScope (lifetime) of the session.
spring.data.neo4j.uri URI used by the driver detected by default.
spring.data.neo4j.username Login user of the server.
NEO4J Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

ATOMIKOS Spring Boot Properties

ATOMIKOS is a provider of Spring Boot for handling transactions atomicity in global transactions involving heterogeneous components. To use ATOMIKOS transaction manager in your Spring boot application you have to add this ATOMIKOS starter in your pom.xml .

<dependency>
      <groupId>com.atomikos</groupId>
      <artifactId>transactions-spring-boot-starter</artifactId>
   </dependency>

After adding ATOMIKOS starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Atomikos Configuration Properties

Spring Boot load these properties in AtomikosProperties class.

NameDefault ValueDescription
spring.jta.atomikos.connectionfactory.borrow-connection-timeout30Timeout for borrowing connections from the pool. (in seconds)
spring.jta.atomikos.connectionfactory.ignore-session-transacted-flagtrueSet to ignore the transacted flag when creating session.
spring.jta.atomikos.connectionfactory.local-transaction-modefalseSet local transactions are desired.
spring.jta.atomikos.connectionfactory.maintenance-interval60The time between runs of the pool’s maintenance thread. (in seconds).
spring.jta.atomikos.connectionfactory.max-idle-time60The time after which connections are cleaned up from the pool. (in seconds)
spring.jta.atomikos.connectionfactory.max-lifetime0The time that a connection can be pooled for before being destroyed. 0 denotes no limit.(in seconds)
spring.jta.atomikos.connectionfactory.max-pool-size1The maximum pool size.
spring.jta.atomikos.connectionfactory.min-pool-size1The minimum pool size.
spring.jta.atomikos.connectionfactory.reap-timeout0The reap timeout for borrowed connections. 0 denotes no limit.( in seconds)
spring.jta.atomikos.connectionfactory.unique-resource-namejmsConnectionFactoryThe unique name used to identify the resource during recovery.
spring.jta.atomikos.datasource.borrow-connection-timeout30Timeout for borrowing connections from the pool. (in seconds)
spring.jta.atomikos.datasource.default-isolation-level Default isolation level of connections provided by the pool.
spring.jta.atomikos.datasource.login-timeout Timeout for establishing a database connection.(in seconds)
spring.jta.atomikos.datasource.maintenance-interval60The time between runs of the pool’s maintenance thread.(in seconds)
spring.jta.atomikos.datasource.max-idle-time60The time after which connections are cleaned up from the pool.(in seconds)
spring.jta.atomikos.datasource.max-lifetime0The time that a connection can be pooled for before being destroyed. 0 denotes no limit.(in seconds)
spring.jta.atomikos.datasource.max-pool-size1The maximum pool size.
spring.jta.atomikos.datasource.min-pool-size1The minimum pool size.
spring.jta.atomikos.datasource.reap-timeout0The reap timeout for borrowed connections. 0 denotes no limit.(in seconds)
spring.jta.atomikos.datasource.test-query SQL query or statement used to validate a connection before returning it.
spring.jta.atomikos.datasource.unique-resource-namedataSourceThe unique name used to identify the resource during recovery.
spring.jta.atomikos.properties.checkpoint-interval500Interval between checkpoints.
spring.jta.atomikos.properties.default-jta-timeout10000Default timeout for JTA transactions.
spring.jta.atomikos.properties.enable-loggingtrueEnable disk logging.
spring.jta.atomikos.properties.force-shutdown-on-vm-exitfalseSpecify if a VM shutdown should trigger forced shutdown of the transaction core.
spring.jta.atomikos.properties.log-base-dir Directory in which the log files should be stored.
spring.jta.atomikos.properties.log-base-nametmlogTransactions log file base name.
spring.jta.atomikos.properties.max-actives50Maximum active transactions.
spring.jta.atomikos.properties.max-timeout300000Maximum timeout that can be allowed for transactions. (in milliseconds)
spring.jta.atomikos.properties.serial-jta-transactionstrueSpecify if sub-transactions should be joined when possible.
spring.jta.atomikos.properties.service Transaction manager implementation that should be started.
spring.jta.atomikos.properties.threaded-two-phase-committrueUse different (and concurrent) threads for two-phase commit on the resources.
spring.jta.atomikos.properties.transaction-manager-unique-name Transaction manager’s unique name.
ATOMIKOS Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Leaning !!!

BITRONIX Spring Boot Properties

BITRONIX is a provider of Spring Boot for handling distributed transaction. To use BITRONIX transaction manager in your Spring boot application you have to add this BITRONIX starter in your pom.xml .

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-jta-bitronix</artifactId>
 </dependency>

After adding BITRONIX starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

BiTronix Configuration Properties

NameDefault ValueDescription
spring.jta.bitronix.connectionfactory.acquire-increment1Number of connections to create when pool grow.
spring.jta.bitronix.connectionfactory.acquisition-interval1Time to wait before trying to acquire a connection again after an invalid connection was acquired.(in second)
spring.jta.bitronix.connectionfactory.acquisition-timeout30Timeout for acquiring connections from the pool. (in second)
spring.jta.bitronix.connectionfactory.allow-local-transactionstrueSet the transaction manager should allow mixing XA and non-XA transactions.
spring.jta.bitronix.connectionfactory.apply-transaction-timeoutfalseSet the transaction timeout should be set on the XAResource when it is enlisted.
spring.jta.bitronix.connectionfactory.automatic-enlisting-enabledtrueSet resources should be enlisted and delisted automatically
spring.jta.bitronix.connectionfactory.cache-producers-consumerstrueSet produces and consumers should be cached.
spring.jta.bitronix.connectionfactory.defer-connection-releasetrueSet the provider can run many transactions on the same connection and supports transaction interleaving.
spring.jta.bitronix.connectionfactory.ignore-recovery-failuresfalseSet recovery failures should be ignored.
spring.jta.bitronix.connectionfactory.max-idle-time60The time after which connections are cleaned up from the pool.(in second)
spring.jta.bitronix.connectionfactory.max-pool-size10The maximum pool size. 0 denotes no limit.
spring.jta.bitronix.connectionfactory.min-pool-size0The minimum pool size.
spring.jta.bitronix.connectionfactory.password The password to use to connect to the JMS provider.
spring.jta.bitronix.connectionfactory.share-transaction-connectionsfalseSet connections in the ACCESSIBLE state can be shared within the context of a transaction.
spring.jta.bitronix.connectionfactory.test-connectionstrueSet connections should be tested when acquired from the pool.
spring.jta.bitronix.connectionfactory.two-pc-ordering-position1The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE).
spring.jta.bitronix.connectionfactory.unique-namejmsConnectionFactoryThe unique name used to identify the resource during recovery.
spring.jta.bitronix.connectionfactory.use-tm-jointrue Set TMJOIN should be used when starting XAResources.
spring.jta.bitronix.connectionfactory.user The user to use to connect to the JMS provider.
spring.jta.bitronix.datasource.acquire-increment1Number of connections to create when growing the pool.
spring.jta.bitronix.datasource.acquisition-interval1Time to wait before trying to acquire a connection again after an invalid connection was acquired.(in second)
spring.jta.bitronix.datasource.acquisition-timeout30Timeout for acquiring connections from the pool. (in second)
spring.jta.bitronix.datasource.allow-local-transactionstrueSet the transaction manager should allow mixing XA and non-XA transactions.
spring.jta.bitronix.datasource.apply-transaction-timeoutfalseSet the transaction timeout should be set on the XAResource when it is enlisted.
spring.jta.bitronix.datasource.automatic-enlisting-enabledtrueSet resources should be enlisted and delisted automatically.
spring.jta.bitronix.datasource.cursor-holdability The default cursor holdability for connections.
spring.jta.bitronix.datasource.defer-connection-releasetrueSet the database can run many transactions on the same connection and supports transaction interleaving.
spring.jta.bitronix.datasource.enable-jdbc4-connection-test Set Connection.isValid() is called when acquiring a connection from the pool.
spring.jta.bitronix.datasource.ignore-recovery-failuresfalseSet recovery failures should be ignored.
spring.jta.bitronix.datasource.isolation-level The default isolation level for connections.
spring.jta.bitronix.datasource.local-auto-commit The default auto-commit mode for local transactions.
spring.jta.bitronix.datasource.login-timeout Timeout for establishing a database connection.(in second)
spring.jta.bitronix.datasource.max-idle-time60The time after which connections are cleaned up from the pool.(in second)
spring.jta.bitronix.datasource.max-pool-size10The maximum pool size. 0 denotes no limit.
spring.jta.bitronix.datasource.min-pool-size0The minimum pool size.
spring.jta.bitronix.datasource.prepared-statement-cache-size0The target size of the prepared statement cache. 0 disables the cache.
spring.jta.bitronix.datasource.share-transaction-connectionsfalseSet connections in the ACCESSIBLE state can be shared within the context of a transaction.
spring.jta.bitronix.datasource.test-query SQL query or statement used to validate a connection before returning it.
spring.jta.bitronix.datasource.two-pc-ordering-position1The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE).
spring.jta.bitronix.datasource.unique-namedataSourceThe unique name used to identify the resource during recovery.
spring.jta.bitronix.datasource.use-tm-jointrue Set TMJOIN should be used when starting XAResources.
spring.jta.bitronix.properties.allow-multiple-lrcfalseAllow multiple LRC resources to be enlisted into the same transaction.
spring.jta.bitronix.properties.asynchronous2-pcfalseEnable asynchronously execution of two phase commit.
spring.jta.bitronix.properties.background-recovery-interval-seconds60Interval at which to run the recovery process in the background.(in seconds)
spring.jta.bitronix.properties.current-node-only-recoverytrueRecover only the current node.
spring.jta.bitronix.properties.debug-zero-resource-transactionfalseLog the creation and commit call stacks of transactions executed without a single enlisted resource.
spring.jta.bitronix.properties.default-transaction-timeout60Default transaction timeout.(in second)
spring.jta.bitronix.properties.disable-jmxfalseEnable JMX support.
spring.jta.bitronix.properties.exception-analyzer Set the fully qualified name of the exception analyzer implementation to use.
spring.jta.bitronix.properties.filter-log-statusfalseEnable filtering of logs so that only mandatory logs are written.
spring.jta.bitronix.properties.force-batching-enabledtrueSet if disk forces are batched.
spring.jta.bitronix.properties.forced-write-enabledtrueSet if logs are forced to disk.
spring.jta.bitronix.properties.graceful-shutdown-interval60Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
spring.jta.bitronix.properties.jndi-transaction-synchronization-registry-name JNDI name of the TransactionSynchronizationRegistry.
spring.jta.bitronix.properties.jndi-user-transaction-name JNDI name of the UserTransaction.
spring.jta.bitronix.properties.journaldiskName of the journal. Can be ‘disk’, ‘null’ or a class name.
spring.jta.bitronix.properties.log-part1-filenamebtm1.tlogName of the first fragment of the journal.
spring.jta.bitronix.properties.log-part2-filenamebtm2.tlogName of the second fragment of the journal.
spring.jta.bitronix.properties.max-log-size-in-mb2Maximum size in megabytes of the journal fragments.
spring.jta.bitronix.properties.resource-configuration-filename ResourceLoader configuration file name.
spring.jta.bitronix.properties.server-id ASCII ID that must uniquely identify this TM instance. Default to the machine’s IP address.
spring.jta.bitronix.properties.skip-corrupted-logsfalseSkip corrupted transactions log entries.
spring.jta.bitronix.properties.warn-about-zero-resource-transactiontrueLog a warning for transactions executed without a single enlisted resource.
BITRONIX Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

NARAYANA Spring Boot Properties

Narayana is a popular open source JTA transaction manager implementation supported by Red Hat. To use Narayana JTA in your Spring Boot application you can use You can use the narayana-spring-boot-starter starter to add the appropriate Narayana dependencies to your application.

NARAYANA pom.xml Dependencies

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jta-narayana</artifactId>
</dependency>

Spring Boot automatically configures Narayana with default values and post-processes your beans to ensure that startup and shutdown ordering is correct.

NARAYANA Spring Boot Properties

Spring Boot load these properties in NarayanaProperties class with default values you can overwrite these values in your application application.properties/ application.yaml.

NameDefault ValueDescription
spring.jta.narayana.default-timeout60Transaction timeout.(in second)
spring.jta.narayana.expiry-scannerscom.arjuna.ats.internal. arjuna.recovery. ExpiredTransactionStatusManagerScannerComma-separated list of expiry scanners.
spring.jta.narayana.log-dir Transaction object store directory.
spring.jta.narayana.one-phase-committrueEnable one phase commit optimisation.
spring.jta.narayana.periodic-recovery-period120Interval in which periodic recovery scans are performed.(in second)
spring.jta.narayana.recovery-backoff-period10Back off period between first and second phases of the recovery scan.(in second)
spring.jta.narayana.recovery-db-pass Database password for recovery manager.
spring.jta.narayana.recovery-db-user Database username for recovery manager.
spring.jta.narayana.recovery-jms-pass JMS password for recovery manager.
spring.jta.narayana.recovery-jms-user JMS username for recovery manager.
spring.jta.narayana.recovery-modules Comma-separated recovery modules.
spring.jta.narayana.transaction-manager-id1Unique transaction manager id.
spring.jta.narayana.xa-resource-orphan-filters Comma-separated orphan filters.

By default, Narayana transaction logs written location is  transaction-logs directory in your application home directory (the directory in which your application jar file resides). You can customize the location of this directory by setting the narayana.log-dir or spring.jta.log-dir similar to that you can also customize the other properties.

References

Happy Learning !!!