Category: Uncategorized

Multiple databases with Spring Boot and Spring Data JPA

A little while back I knocked up a post describing how to enable a Spring application to connect to multiple data sources. At the time, I had only just heard about Spring Boot at the SpringOne 2GX conference in Santa Clara, so the examples didn’t take advantage of that and also didn’t work around some of the autowiring that it does.

Recently, I was working on a little ETL project to migrate data from one database to another with a different structure, so I returned to this problem and the following is the result.

Continue reading “Multiple databases with Spring Boot and Spring Data JPA”

A BigDecimal accumulator for Drools

Working in the financial industry, I have become rather strict about avoiding doubles in Java. The trouble is that they are a floating point representation of a number, which is just an approximation of the real value. This can lead to some unusual results.

For instance, according to this, 0.34 + 0.01 is not equal to 0.35.

double x = 0.35;
double y = 0.34 + 0.01;
System.out.println(x + " : " + y + " : " + (x == y));
0.35 : 0.35000000000000003 : false

Those inaccuracies might seem very small, but it’s surprisingly easy for them to start impacting a real world application. Imagine you wanted to sell dollars and buy Iranian Rial. You would be getting almost 20,000 Rial for every dollar. At that rate, imprecise floating point values could easily impact the final amount being sent. Although with the current US trade sanctions against Iran, that could be the least of your problems.

Continue reading “A BigDecimal accumulator for Drools”

WebLogic Scripting Tool – Scripts

Originally posted @ on April 5th 2008.

I mentioned my use of the WebLogic Scripting Tool a little while back. I have noticed since then that a number of folks visiting this site are looking for example scripts. I have obviously written a number myself and I promise I’ll try to get around to posting them here. However until I get myself in gear, I thought I would point you at some useful examples that are already out there. I’ll expand this post as I find more…

Continue reading “WebLogic Scripting Tool – Scripts”

Open source financial libraries for Java

Originally posted @ on April 16th, 2007.

The financial industry does seem to be loath to share the fruits of their efforts. There doesn’t seem to be a lot around. And certainly not much that is regularly updated. Maybe everyone is worried about sharing trade secrets, but the rules for calculations are well established and I’m guessing that everyone must be writing their own implementations or buying in over-priced modules.

Continue reading “Open source financial libraries for Java”