Home » Core Java » apache » commons


DBCP Connection Pooling Example

We will be writing a series of examples demonstrating how to configure Connection Pooling in your Java Application using different libraries like DBCP, C3P0, HikariCP etc. In this example, we shall demonstrate how to achieve connection pooling using the Apache DBCP library. 1. Why use Connection Pooling? To present dynamic data to the users, an application typically connects to a ...

Read More »

org.apache.commons.net.ftp.ftpclient Example

In this example we are going to elaborate the use of the FTPClient class in the package: org.apache.commons.net.ftp, as the package name says, it is a member of the Apache Commons, and deals with the FTP. As like other classes of the Apache Commons This class also provides us with some really helpful methods. The methods of this class as other classes ...

Read More »

org.apache.commons.dbcp2.PoolingConnection Example

In this example, we shall show you how to use PoolingConnection of Apache commons dbcp2 library. DBCP is a part of Apache common components and intended for database connection pooling. PoolingConnection is a delegating connection that pools java.sql.PreparedStatement. The prepared statement will be either created or returned from the pool by PoolingConnection as shown in example below. Clients of this class needs ...

Read More »

org.apache.commons.codec.binary.Base64OutputStream Example

Base64OutputStream has constructors with parameter for encoding (default behavior) and decoding in a streaming fashion for unlimited size. The default line length is 76 characters for encoding. The default lineEnding is CRLF. Base64InputStream has default behavior for decoding. There are other constructors for Base64OutputStream and Base64InputStream has different constructors to override default behavior. Base64OutputStream takes byte streams instead of character ...

Read More »

org.apache.commons.dbcp.BasicDataSource Example

In this example, we shall show you how to use BasicDataSource of Apache commons dbcp library. DBCP is a part of apache common components and intended for database connection pooling. BasicDataSource is a basic implementation of javax.sql.DataSource Using BasicDataSource, one can easily connect to a Relational Database as we will show in following example. For this example, we will be using ...

Read More »

org.apache.commons.logging.logfactory Example

In this example, we shall be talking about how we can use the Apache commons org.apache.commons.logging.Logfactory class. You can download the apache commons logging Jar file from here. The Logfactory class uses the Factory Design Pattern to select a logger class. The Apache Commons Logging library decouples the code from the underlying logging library we use.     The Logger ...

Read More »

org.apache.commons.codec.binary.base64 Example

Base64 class is used for  Base64 encoding and decoding as defined by RFC 2045.  There are various constructors with  URL-Safe mode, Line Length and Line Separator parameters. The URL Safe parameter is used to encode operations. Decoding handles URL safe mode on and off.  Bytestreams are used directly by Base64 class. Character streams are not used. ThreadSafe Base64 class has ...

Read More »

org.apache.commons.dbcp2.BasicDataSource Example

In this example we shall show you how to make use of BasicDataSource class of Apache Commons DBCP. Nowadays, many web applications interacts with a relational database, Creating a new connection for each user can be time consuming (often requiring multiple seconds of clock time), in order to perform a database transaction that might take milliseconds. Opening a connection per ...

Read More »

java.net.URLConnection Example

URLConnection class is used for accessing the attributes of a remote resource. It represents a communication link between the URL and the application.This class can be used to read and write data to resource provided by the URL. URLConnection has subclasses HttpURLConnection which has support for HTTP-specific features and JarURLConnection which has support for JAR-specific features. In this example we ...

Read More »

org.apache.commons.dbcp2.PoolableConnection Example

In this post we learn how to use a connection’s pool using the apache commons dbcp2 framework. A connection pool is an object that maintains a pool of opened connections so the application can simply grab one when it needs to, use it, and then hand it back, eliminating much of the long wait of the creation of connections. 1. ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns