In Java JPA, you can define composite keys of using the @EmbeddedId annotation. For example, you have a table called contact and you want to use the columns firstname and lastname as the composite keys.
Continue reading Java JPA – Using Composite Keys
Category Archives: Java
Java – Creating an RSA key pair in Java
Keys can be used for Data Encryption and Digital Signing. They can be generated by OpenSSL which i have talked about in a previous article.
Actually, the Java JDK also provides API for creating key pair. Continue reading Java – Creating an RSA key pair in Java
Java Cryptography Extension – Remove JCE Key Size Restriction
As we talked about yesterday, the default JDK has a limitation on key size which is bounded by the JCE Jurisdiction Policy.
But actually, Java provides a JCE Patch such that you can remove the restriction on key size.
The patch is called Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files which can be download at Java SE Downloads.
Continue reading Java Cryptography Extension – Remove JCE Key Size Restriction
Java Cryptography Extension – Check Maximum Allowed Key Size
In Java, there is a limitation on key size by the JCE Jurisdiction Policy. If you manipulate a private key with bit size which is larger than the limitation, it will throw a InvalidKeyException complaining about Illegal key size.
The following piece of Java code will check maximum key size of all the algorithms and print the result to the console. Continue reading Java Cryptography Extension – Check Maximum Allowed Key Size
Apache log4j – log4j.properties Configuration
Apache log4j is commonly used in Java for logging purpose. This post guides you how to make use of it in your Java program.
In a Maven project, just add the following dependency in the pom.xml. Continue reading Apache log4j – log4j.properties Configuration
PHP – Run a Java Program in PHP
Running a Java program in PHP just like running the shell command as i mentioned yesterday.
Continue reading PHP – Run a Java Program in PHP
CentOS – Install Java Sun JDK
If you want to use Java Sun JDK instead of OpenJDK on CentOS, u have to install it manually.
Continue reading CentOS – Install Java Sun JDK
Java – Date validation using SimpleDateFormat
I need to write a program which reads a date string. The program then archives all the data on the server with the input date as an cut off date.
The following java program is based on the tutorial in </dream.in.code>. It reads a date string, validate it and print the number of date difference between today and the input date.
Continue reading Java – Date validation using SimpleDateFormat
Java – Get the content of inputStream from HttpServletRequest
Recently, i got a support case and it is about the inconsistency of the content length declared in the http header and the actual content length of the http request.
So i modified an existing program which will get the http request and manipulate it. I add some codes such that it will get the request inputStream and count it byte by byte before the request manipulation.
Continue reading Java – Get the content of inputStream from HttpServletRequest
JDBC – Java Database Connectivity @ 3
By default, the auto commit property of the database connection is set to true. So if you want to rollback the transaction in case there is an exception, you have to set the auto commit to false.
Continue reading JDBC – Java Database Connectivity @ 3