Home » Java

Java

Apache Derby Database Users and Permissions

Abstract Apache Derby is awesome! Especially in a Microservices environment where the data for services (may) shrink and not require a heartier RDBMS. Derby is awesome because it’s so easy to use, especially when it come to users and permissions – you don’t need any! But, it may be the case you want to create an application-level user with limited ...

Read More »

Making Pivot Tables with Java Streams from Databases

Raw data from database rows and tables does not provide so much insight to human readers. Instead, humans are much more likely to see data patterns if we perform some kind of aggregation on the data before it is being presented to us. A pivot table is a specific form of aggregation where we can apply operations like sorting, averaging, ...

Read More »

New JDK 11 Files Method isSameContent()

It has been proposed that a method named isSameContents() be added to the Files class in JDK 11 via JDK-8202285 [“(fs) Add a method to Files for comparing file contents”]. Proposed by Joe Wang, this new method is “intended to be an extension to the existing isSameFile method since it stopped short of comparing the content to answer the query ...

Read More »

TestContainers and Spring Boot

spring-interview-questions-answers

TestContainers is just awesome! It provides a very convenient way to start up and CLEANLY tear down docker containers in JUnit tests. This feature is very useful for integration testing of applications against real databases and any other resource for which a docker image is available. My objective is to demonstrate a sample test for a JPA based Spring Boot ...

Read More »

New JDK 11 Files Methods for Reading/Writing Strings From/To Files

My previous post focused on the Files.isSameContent() method that is likely to be added to JDK 11. JDK-8201276 [“(fs) Add methods to Files for reading/writing a string from/to a file”] mentions this new method and also highlights the methods that are the subjects of this post: readString(Path) readString(Path, Charset) writeString(Path, CharSequence, OpenOption...) writeString(Path, CharSequence, Charset, OpenOption...) Joe Wang recently posted ...

Read More »

Using Java Stream summary statistics

Streams of primitive types (IntStream, etc.) provide a summaryStatistics() method that can be used to get multiple statistical properties of a stream (minimum value, average value, etc.). Assume we have a list of people. Our goal is to get the minimum and maximum age of the people in the list using streams. The problem here is that the computation of ...

Read More »

Secure a Spring Microservices Architecture with Spring Security and OAuth 2.0

spring-interview-questions-answers

“I love writing authentication and authorization code.” ~ No Java Developer Ever. Tired of building the same login screens over and over? Try the Okta API for hosted authentication, authorization, and multi-factor auth. Every developer wants to build faster and more efficiently, to support scale. Building a microservices architecture with Spring can add resilience and elasticity to your architecture that ...

Read More »

Java 8 filter & map & collect & Stream Example

Hello guys, many of my readers emailed me to write a post about map and filter function of Java 8 because they found it difficult to understand and use. Even though I have previously blogged about both map() and filter(), I am writing this post again to explain the concept in more layman’s language for better understanding of my readers and fellow Java ...

Read More »

Predicate::not Coming to Java

Jim Laskey’s recent message “RFR: CSR – JDK-8203428 Predicate::not” on the OpenJDK core-libs-dev mailing list calls out JDK Bug JDK-8203428 [“Predicate::not”]. The “Summary” of JDK-8203428 states, “Introduce a new static method Predicate::not which will allow developers to negate predicate lambdas trivially.” It is currently assigned to JDK 11. The “Problem” section of JDK-8203428 provides a succinct description of the issue ...

Read More »