Thrift is one of the most popular remote procedure call (RPC) frameworks. You can use it to build cross-platform system. In this page I will show you how to use it in Java.
Using StringBuilder or StringBuffer is more efficient then String when you need append some strings. There is a problem when use them in loop. We have to remove the last character when end the loop. Today I will show you how to remove last character when you use StringBuilder or StringBuffer.
In this page I will show you how to use BlockingQueue. Producer put products into BlockingQueue and consumer consumes the products one by one. The products in BlockingQueue will be consumed on a FIFO (first-in-first-out) basis. Sample code is like following.
In this blog I will show you how to use Future and Callable to get the result asynchronously. Write your logic code in call method of Callable then submit it and get Future. isDone method in Future class can help you to get the result of your task. get method of Future class will get the result of your task, this method will block the thread if the task doesn't finish. Sample code is like following.
It is easy to serialize object to byte array and deserialize byte array to object. Today I will show you how to serialize and deserialize object when it changed.
In this page I will show you how to use interceptor in Spring Boot. You can use interceptor handling common business logic. The structure of project is like following.
In this page I will show you how to make MySQL to support remote accessing. I assume you install MySQL in your environment and local login successfully. Before remote accessing we need creating a database.
When you see "Your password does not satisfy the current policy requirements" error message that means your password is not safe. MySQL use validate_password plugin to test passwords and improve security. There are 3 levels in validate_password_policy. You can check the value of it by using following command.
In last blog I have introduced how to install MySQL in CentOS. In this page I will show you how to login MySQL for the first time.
In this page I will show you how to install MySQL in CentOS. My environment is CenOS6, it is almost same steps to install MySQL in other version of CentOS. We assume that you have install CentOS successfully.
I have wrote a tutorial how to generator Mybatis entity and mapper by using idea Mybatis plugin. In this blog I will how you how to generator Mybatis entity and mapper by using maven plugin. Before using IDEA plugin you need pay for it, maven plugin is free instead.
File separator is "/" on UNIX and "\" on Windows. Using FilenameUtils convert path between windows and UNIX is easily. FilenameUtils.separatorsToSystem method can help you to use correct separator.
It is easy using Jackson to convert JSON string to Object. In this page I will show you how to convert JSON string to generic object with Jackson. TypeReference is very useful when you convert json string to generic object (like Map, List or other generic object).
The code below shows how to calculate relative time. Invoke getRelativeTime method by passing a timestamp.
You will get UnrecognizedPropertyException if you convert json string to object with unknown field. There are 2 ways to avoid this problem. Use JsonIgnoreProperties annotation or add DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES to ObjectMapper configuration. Examples are in the following.