
Posted In: Database, MySQL
MySQL AUTO_INCREMENT column
In case you worked most of life on Oracle DB you must be wondering where is the SEQUENCE. AUTO_INCREMENT column in MySQL is used for primary key column. For each insert MySQL will automatically update the column to next max value. For each new row, MySQL increments the value automatically and persist it to table. […]
Read More
Posted In: IO, Java Core
How to create a temporary file/directory in Java
JDK 7 createTempDirectory and createTempFile method creates temp folder with given suffix. I have also added deleteOnExit to delete temp folder but dir.toFile().deleteOnExit() does not seem to be reliable on Windows. package com.example.java.core; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.Test; public class TempFile { @Test public void create() throws Exception { Path dir = […]
Read More
Posted In: Date, Java Core
Convert java.util.Date to java.time.LocalDate, LocalDateTime
Date date1 = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”) .parse(“2017-08-13 12:10:30”); LocalDate localdate = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); LocalDateTime localdatetime = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();
Read More
Posted In: Date, Java Core
Comparing two Dates without the time portion
Techniques used 1. JODA Time DateTimeComparator 2. Apache Commons DateUtils 3. JDK 8 LocalDate 4. Below JDK 8 DateFormat
Read More
Posted In: Security
How to encrypt Password/String using Bouncy castle library
Bouncy castle library Maven bcprov-jdk16
Read More
Posted In: Apache, Commons, Security
How to encrypt Password/String using Apache Crypto
Apache Crypto library Maven commons-crypto Original Example
Read More
Posted In: Security
How to encrypt Password/String using Jasypt library
Jasypt library provide multiple methods to encrypt a password Maven jasypt
Read More
Posted In: Apache, Commons, Security
How to encrypt Password/String using Apache Codec
Apache codec provide multiple methods to encrypt a string Maven commons-codec
Read More
Posted In: Java Core
How to determine the size of an object in Java
JDK 5 provides Instrumentation interface which can be used find Object Size Instrumentation set up requires entry to manifest file Premain-Class: ObjectAgent and use public static void premain(String agentArgs, Istrumentation instrumentation). There is little easy way to do it. Use memory-measurer Run class with javaagent VM argument
Read More
Posted In: Java Core, String
String vs StringBuilder vs StringBuffer Simple Benchmark test
Since String is immutable in java any changes to it creates a new object. StringBuffer and StringBuilder are mutable objects. They provide methods like append(), insert(), delete() and substring() to manipulate date. This test clearly shows that always use StringBuilder. It will perform much better than String concatenation. Result
Read More- Apache (13)
- Build Tools (2)
- Gradle (2)
- Caching (1)
- cpanel (1)
- cURL (1)
- Database (7)
- Hibernate (5)
- Java Core (38)
- Java Script (15)
- Bootstrap (1)
- File Upload (7)
- jQuery (3)
- React (3)
- JEE (13)
- JSON (41)
- GSON (13)
- Jackson 1X (1)
- Jackson 2X (12)
- jsoniter (1)
- Logging (2)
- Apache Commons Logging (1)
- Apache Log4J (1)
- Logback (1)
- SLF4J (1)
- MongoDB (1)
- OS (1)
- Linux (1)
- Security (5)
- Server (4)
- Tomcat (4)
- Service (2)
- Micro (2)
- Spring (46)
- Pattern (2)
- Spring Boot (20)
- Spring Data (4)
- Spring MVC (8)
- Spring REST (13)
- Spring Security (7)
- Testing (11)
- XML (5)
- JDOM XML Parser (1)