Home » Archives for Chandan Singh » Page 5

Author Archives: Chandan Singh

Chandan holds a degree in Computer Engineering and is a passionate software programmer. He has good experience in Java/J2EE Web-Application development for Banking and E-Commerce Domains.

XPath local-name example

Continuing on the series of examples about XPath, we will see how we can use the local-name function in Java. We use this XPath function we need to work with namespaces. What are namespaces? Namespaces are used to avoid conflicts in the tag-names. The tags have a prefix defined by the xmlns attribute(short for XML namespace).     Let’s see ...

Read More »

XPath String functions example

In the previous examples, we talked about how we can query for a particular node(s) and extract the attribute value from a node in an XML Document. In this example, we shall see what other String operations on XPath are supported by the Java programming language. The String operations are a range of functions that may be used to search/query. ...

Read More »

XPath get attribute value example

Continuing on our previous example on how to search for a text using XPath, we shall demonstrate how to get an attribute value from an XPath Node. As we already know, the @ attribute is used to denote an attribute in the XPathExpression. So we shall use extract the attribute value by specifying the node selector in the expression. In ...

Read More »

XPath contains text example

In this example, we shall study how to search for a particular text using XPath in Java. What is XPath? XPath is a query language used to define/select parts of an XML Document using variety of criteria. Java provides all the utility classes for using XPath in the javax.xml.xpath package. XPath uses pattern to filter out the matching nodes. The ...

Read More »

JPA Native SQL Queries Example

In this example, we shall see how to use native SQL queries in JPA. The Java Persistence Query Language is a powerful query language that can be used to bridge the Object Relational world. However, there are cases when the JPQL falls short for example, to execute a Stored Procedure. The JPA optimizes the query written in JPQL for the ...

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 »

Java.net.URLClassLoader Example

In this example, we shall see how we can use the java.net.URLClassLoader Class in the java.net package for loading the classes dynamically. The URLClassLoader class Loads the classes and other resources at runtime from a directory or a JAR file. It has constructors that accept an array of URL class, URL[] and delegating parent Class-Loader, optionally.         ...

Read More »

JPA EntityManager Example

In this example, we shall try to demonstrate how to use JPA EntityManager. As the name suggests, an EntityManager is a class that manages the state of the Entity(Persist/Update/Delete etc). Every EntityManager object has an instance of EntityTransaction associated with it. EntityTransaction is used to manage the transactions. We shall be using Hibernate as the JPA Vendor. The underlying database ...

Read More »

Tomcat DataSource JNDI Example

In this example, we shall demonstrate how to create the Data-source using Java Naming and Directory Interface or JNDI, for short. The JNDI Data-source created in web-server uses one of the connection pooling libraries like DBCP, C3P0 or the BoneCP. The connection pool can be created in the Web-Server or it can also be created in the web-application, itself. Creating ...

Read More »

JDBC Batch Processing Example

In this example, we will see how we can use Batch Processing in Java Database Connectivity(i.e.JDBC). When multiple inserts are to be made to the table in a database, the trivial way is to execute a query per record. However, this involves acquiring and releasing connection every time a record is inserted, which hampers application performance. We overcome, this(acquiring and ...

Read More »