One of the first things we do to a database is to create tables. SQL supports data definition language or data description language (DDL). Using SQL "Create" statements, we can create tables in our database. Below is a simple example on how to use Groovy SQL to create a table in the database.
When working with database in Groovy, the first thing we want to do is to connect to a database server. We will not be able to read or manipulate data unless we have a connection. Below will show a simple example on how to connect to a MySQL database in Groovy.
The String class in Groovy has the tokenize() method as a convenient way to tokenize a String or character sequence and return the result as List of String. The given String or character sequence is delimited by whitespace as a default, or can be used passing delimiter as a paramater. Below are some examples on how to use Groovy String's tokenize() method.
Enum was introduced in Java to represent a fixed set of constants. Since Groovy is a superset of Java, Enums are also supported in the Groovy programming language. Groovy also adds some enhancements to make working with Enums easier. Below are some examples on how to work with Enums in Groovy.
Groovy supports a quick way of declaring a list of sequential values using Ranges. In Groovy, a Range can be defined using the .. or ..< notation to declare a list of sequential values. Below are some examples.
Groovy String has a split() method as a convenience method to split a String or character sequence and return the result as Array of String. The given String or character sequence is split by whitespace as a default, or the given delimiter. Below are some examples on how to use Groovy String's split() method.
A Set is a collection of objects where all elements are unique and with no duplicates. The elements are not ordered and there are no repeating values. This is a very important data structure on certain programming scenarios. Below are some examples on how we declare and manipulate Sets in Groovy.
One of the biggest technical hurdle when learning a new language is setting up your programming environment. This is a short guide on how to install a Groovy IDE to your Windows Workstation with screenshots for those who are new to the Java platform. We choose Eclipse as our Groovy IDE in the tutorial below.
When we are comparing Date instances, we usually just care about the date part and not the time component. For more accurate comparison, it is sometimes desirable to remove the time component from a Date object. Below is an example on how to remove or clear time component from a Date instance in Groovy.