Spring JDBC Dao SQL ‘SELECT’ statement examples
Spring JDBC/Dao FAQ: Can you share some Spring JDBC examples, specifically SELECT query examples using Spring Dao objects?
Spring JDBC/Dao FAQ: Can you share some Spring JDBC examples, specifically SELECT query examples using Spring Dao objects?
As I continue my efforts to organize the content on this site, here is a collection of JOptionPane tutorials and examples.
Java keytool/keystore FAQ: Can you share some Java keytool and keystore command examples?
Sure. As a little bit of background, in creating my "Hyde (Hide Your Mac Desktop)" software application, I decided to venture into the world of commercial software, selling my app for a whopping 99 cents. While that price is trivial, creating the “software licensing” code for this application was anything but trivial.
I finally decided to use a Java licensing tool named TrueLicense to assist with the software licensing, and TrueLicense quickly led me down the path of learning about the Java keytool and keystore path. So that’s what this article is about: How to use the Java keytool
command to work with private and public keys, and work with intermediate certificate files.
Java MySQL INSERT example: Can you share a Java MySQL INSERT example, specifically using a Java PreparedStatement object?
Summary: The Iterator Pattern is demonstrated using Java source code examples.
The Iterator Design Pattern is one of the most simple and frequently used design patterns. The Iterator Pattern lets you sequentially move through a collection of objects using a standard interface, and without having to know the internal representation of that collection.
Summary: A Java “Command Pattern” example is demonstrated.
If you've ever seen Java source code that looks like this:
The Chain of Responsibility Pattern is a design pattern whose intent is to avoid coupling the sender of a request to its receivers by giving more than one object a chance to handle a request. The Chain of Responsibility works like this:
Java file FAQ: Can you share some examples of the Java BufferedReader class?
When it comes to reading character input streams, the Java BufferedReader class is extremely important, and I'll demonstrate this in several different source code examples.
Summary: A discussion of the Strategy Design Pattern using Java source code examples.
The Strategy Design Pattern consists of a number of related algorithms encapsulated in a driver class often named Context. A user or a client program typically selects the algorithm they want to use, although the Context class may also select the algorithm automatically.
The intent of the Strategy Pattern is to make the algorithms easily interchangeable, and provide a means to choose the appropriate algorithm at a particular time.
I've recently started writing a series of articles on Design Patterns in Java, i.e., Design Patterns explained using Java source code examples. Although it will take me a little while to create each design pattern example, this page will eventually contain links to all of those examples.
If you're not familiar with software design patterns, they're described on Wikipedia like this:
I started writing some Java REST (RESTful) clients lately, and in doing so, I've been looking at several different ways to do this, including using the Apache HttpClient project, the Jersey project, Apache CXF, and more.
I was just reminding myself how to write a generics class in Java, and for some reason while I was doing that I wanted to use the Java 'import static' capability so instead of typing this:
System.out.println("foo");
I could just use this:
out.println("foo");
The only thing you have to do to make this happen is to use this import static statement at the top of your class:
Java String comparison FAQ: Can you share some examples of how to compare strings in Java?
If you’re like me, when I first started using Java, I wanted to use the ==
operator to test whether two String
instances were equal, but that’s not the correct way to do it in Java.
Summary: The Law of Demeter is discussed using Java source code examples.
Whenever you talk to a good, experienced programmer, they will tell you that "loosely coupled" classes are very important to good software design.
The Law of Demeter for functions (or methods, in Java) attempts to minimize coupling between classes in any program. In short, the intent of this "law" is to prevent you from reaching into an object to gain access to a third object's methods. The Law of Demeter is often described this way:
Summary: The Mediator Design Pattern is demonstrated in a Java example (a Java Mediator Pattern example).
I’m considering using Easy Rules as a simple “rules engine” in my Android Football Game application, primarily because (a) there are a ton of “rules” involved in having the computer call offensive and defensive plays, and (b) I’m trying to find a way to simplify that code and make it more maintainable.
The Easy Rules website has a Hello, world demo you can look at to get started, but after that, here is my example.
Java FAQ: How can I use multiple regular expression patterns with the replaceAll
method in the Java String
class?
Here’s a little example that shows how to replace many regular expression (regex) patterns with one replacement string in Scala and Java. I’ll show all of this code in Scala’s interactive interpreter environment, but in this case Scala is very similar to Java, so the initial solution can easily be converted to Java.
Java FAQ: What are the rules about Java arithmetic (multiplication, division) involving mixed data types?
While working on a math problem in Java just a little while ago, I realized that I wasn’t comfortable with the Java mixed-type division rules. That is, I wondered if the result of this equation:
3 / 2
the same as the result of this equation:
3 / 2.0
or this equation:
3.0 / 2.0
I recently learned how to use the Java javapackager command to build a macOS application bundle — i.e., a regular macOS application — from a Java application. In this tutorial I’ll show how to create a Mac application bundle from a simple Java class, in this case a Java Swing class.