Java: Import AWS RDS certificate

To establish secure connection between Java application and AWS MySQL RDS instance the ssl/tls certificate needs to be imported in to JVM.

Step #1: Find Java home

Using the following commands you can find the Java home directory

whereis java
ls -l /etc/alternatives/java

Step #2: backup existing cacerts file for future reference

cp $JAVA_HOME/jre/lib/security/cacerrts $JAVA_HOME/jre/lib/security/cacerrts.original

Here are the steps to import RDS certificate into JVM

wget https://s3.amazonaws.com/rds-downloads/rds-ca-2019-root.pem
openssl x509 -outform der -in rds-ca-2019-root.pem -out rds-ca-2019-root.der
keytool -import -alias rds-root -keystore $JAVA_HOME/jre/lib/security/cacerrts -file rds-ca-2019-root.der
wget https://s3.amazonaws.com/rds-downloads/rds-ca-2019-us-west-2.pem
openssl x509 -outform der -in rds-ca-2019-us-west-2.pem -out rds-ca-2019-us-west-2.der
keytool -import -alias rds-intermediate -keystore $JAVA_HOME/jre/lib/security/cacerts -file rds-ca-2019-us-west-2.der

Step #3: Update JDBC url in your Java application

Here is the sample JDBC url with SSL enabled

jdbc:mysql://aws.rds.com/dname?useUnicode=true&characterEncoding=UTF8&verifyServerCertificate=true&useSSL=true&requireSSL=true

There is no language yet available to replace Java!

There is a perception created in the software development industry that Java is out-dated and Ruby, Python, Scala, etc. are going to take over Java’s position. Some “hyper-enthusiasts” are already left Java platform. Sun’s profit model collapse, Applet, Jini, EJB and JSF heavyweight framework failures added fuel to these campaigns. I still believe no language yet available in the market to replace Java. I don’t have to talk why Java is better because it is proven solution for more than a decade but I would like to talk about how false campaigns are created by “hyper-enthusiasts”. It is easy to fall into these false campaigns because as a developer we want new challenges and something new to learn. Read more of this post

Handling currency calculations in Java business application

Recently I saw a weird floating issue in Java application which made our currency calculation wrong. Can you guess what would be the output of the below code?

System.out.println(38.0 - 26.6);

Read more of this post

Java – Thread’s stack trace dump

Recently I was dealing with a deadlock issue. Usually I use eclipse break points to create deadlock situation at the same time find the line/code which causes the deadlock. But this one is bit complex scenario where it is not easy to have break points move line by line to reproduce the deadlock. Read more of this post

A JSP code to debug class loader issues

Class Loader is one of the complex concept/design to understand in Java programming. On the initial days working with Tomcat and Desktop application there is not much class loading issues. From EJB days class loading became complex by specification and implementation. Seems JavaEE 5 tries to simplify the class loading specification but I don’t know much about that. Read more of this post

JEXL – A simple expression evaluation engine

When I was developing a framework looking for a solution very similar to eval() function in JavaScript. Initially I thought of Velocity but somehow I wasn’t convinced with that approach. (Struts2 uses Velocity to externalize the HTML generation to make it customizable). Later I wrote my own parser to evaluate an expression that returns a Boolean value. Recently I found an open source which exactly meets my requirement. I don’t have to talk much about this open source you can find lot more information in their website. I thought it might be useful to others as well.
Reference: http://commons.apache.org/jexl/

Connection Pool vs. Thread Pool Settings

Connection Pool and Thread Pool are used to improve performance of applications. Most of us use these poolings with default settings not caring about their configurations or finding optimal values. But the configuration also an important factor in performance tuning. In some sense the connection pool and the thread pool settings are dependent. We will discuss about the dependency in this post. Read more of this post

Java EE – Performance Tuning Tips

Every application goes through some performance issues whether it is an intranet or internet product. As development progresses, more concentration goes to resolving requirement and technical complexities than performance issues. It is essential to introduce a phase in your development life cycle to tune the product performance before it goes to production. Read more of this post

Difference between Thread.sleep() and Object.wait()

One of my favorite interview question is: What is the difference between sleep() and wait() method? The only commonality between these two method is both halts the current thread execution. The purpose and usage are entirely different. Read more of this post

JSF onload action during restore and render response phase

When comparing JSF with action based frameworks like Struts, Webwork, etc. one of the major missing feature is onload action. Read more of this post

Pure Java Print PDF Open Source API

PDF became widely used file format to exchange documents. There are a quite a few open source API available to create PDF document from Java application. Almost there is no good open source API available to view and print the PDF content from Java application. Fortunately sun released a open source API to fill this gap. Read more of this post

Back to Basics: Statement vs. Prepared Statement

“What is the difference between Statement and Prepared Statement?” this is one of my favorite interview question. Most of the interviewee will say “Statement is not precompiled, prepared statements are precompiled, hence prepared statement will faster than statement”. My next question would be “What do you mean precompile”, the answer will be “the SQL gets compiled and reused”. My last question would be “In which layer the statement gets compiled? (like DB, JDBC, Java Apps.)”, most of them will answer JDBC. Since the answers are abstract, it could be interpreted in either way. Though the prepared statement concept are there for while very few provides in-depth answer. I did googling, the answers are scattered in various sites let me consolidate and give you a comprehensive view. Read more of this post

Web2.0: Hype vs. Reality

If you listen to the Web2.0 sales and marketing (or the research reports funded by Web2.0 vendors) you would think that Web2.0 has swept the enterprise. What does this mean to the masses of enterprise product product development companies? Nothing. Read more of this post

Why JavaScript framework is important?

In the past few years AJAX, Web2.0 and RIA are a few of the most used jargon words in Web development world. How many Java web architect/developer really know how to develop these type of web applications?

Read more of this post

Arbitrary validation in JSF using validator attribute

Recently I was searching for an example about the arbitrary validation in JSF component, found very minimal examples in the web. Here I would like to share my knowledge on this.

Read more of this post