Home » Archives for Ilias Tsagklis » Page 31

Author Archives: Ilias Tsagklis

Avatar photo
Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

Handle SQL warning example

Bipartite Graph

In this example we shall show you how to handle SQL Warnings in Java. To handle SQL Warnings one should perform the following steps: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the Oracle JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) ...

Read More »

Commit/Rollback transaction example

Bipartite Graph

This is an example of a commit and a rollback transaction in Java. Handling commit and rollback transactions in Java implies that you should: Load the JDBC driver, using the forName(String className) API method of the Class. In this example we use the Oracle JDBC driver. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) ...

Read More »

Connect to SQLServer database example

Bipartite Graph

With this example we are going to demonstrate how to connect to SQLServer Database in Java. In short, to connect to SQLServer Database you should: Load the NetDirect JDBC driver, using the forName(String className) API method of the Class, in order to connect to SQLServer Database. Create a Connection to the database. Invoke the getConnection(String url, String user, String password) ...

Read More »

Format number with custom NumberFormat

Bipartite Graph

In this example we shall show you how to format a number with a custom NumberFormat. NumberFormat provides the interface for formatting and parsing numbers. It also provides methods for determining which locales have number formats, and what their names are. To format a number with custom NumberFormat one should perform the following steps: Create a new DecimalFormat, using a ...

Read More »

Format date in custom formats with SimpleDateFormat

Bipartite Graph

This is an example of how to format a Date in custom formats, with the SimpleDateFormat. SimpleDateFormat can be used to format and parse dates. Formating a Date in custom format with the SimpleDateFormat implies that you should: Create a new Date. Create a new SimpleDateFormat, using a String pattern. The pattern describes the date and time format. Invoke the ...

Read More »

Format date in default formats with DateFormat

Bipartite Graph

With this example we are going to demonstrate how to format a date in default formats with DateFormat. Default formats are provided by the DateFormat API to control the length of the result, from SHORT, MEDIUM to LONG and FULL. In short, to format a date in default formats with DateFormat you should: Create a new Date. For each one ...

Read More »

Search files in a directory using FutureTask example

Bipartite Graph

In this example we shall show you how to search files in a directory using FutureTask. We have implemented a Class called MatchCounter, that implements the Callable Interface. It is a task that counts the files in a directory and its subdirectories that contain a given keyword. The basics of the example are shown below: The example’s task, MatchCounter is ...

Read More »

Write JAR file Manifest to file

Bipartite Graph

This is an example of how to write a JAR file Manifest to a file. A JAR file is essentially a zip file that contains an optional META-INF directory. In this directory there is a Manifest, that is used to specify meta-information about the jar file and its entries. Writing a JAR file’s Manifest to a file implies that you ...

Read More »

Create Manifest for JAR File

Bipartite Graph

With this example we are going to demonstrate how to create a Manifest for a JAR File. In short, to create a Manifest for a JAR File you should: Create a FileInputStream by opening a connection to an actual file. Create a new Manifest from the specified input stream. Invoke the getMainAttributes() API method of the Manifest to get the ...

Read More »

Compare Logger Level

Bipartite Graph

In this example we shall show you how to compare Logger Level. The logging Level is used to control logging output. Level objects, such as SEVERE, WARNING and INFO are ordered and specified by ordered integers, so in order to compare them, one should perform the following steps: Use three Level constants. Compare the intValues of each Level constant with ...

Read More »