tumblr counter

DBCP Connection Pooling Example

DBCP Connection Pooling Example

DBCP Connection Pooling Example exaplains about how to create and configure a Connection pool using DBCP Datasource

Many Apache projects support interaction with a relational database, DBCP one among them.

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 user can be unfeasible in a publicly-hosted Internet application where the number of simultaneous users can be very large. Accordingly, developers often wish to share a "pool" of open connections between all of the application's current users.

The number of users actually performing a request at any given time is usually a very small percentage of the total number of active users, and during request processing is the only time that a database connection is required. The application itself logs into the DBMS, and handles any user account issues internally

C3P0 Connection Pooling Example

C3P0 Connection Pooling Example

C3P0 Connection Pooling Example exaplains about how to create and configure a Connection pool using C3P0 Datasource

Creating and establishing a database connections are relatively very expensive because of establishing a network connection, initializng database session, authorization in the back end database etc.

Due to this issues, it is good practice to use a connection pool in your applications in order to increase the performance and scalability. By using Connection Pool, you can re-use already existing connections and prepared statements, so that you can avoid the cost of establishing the connection.

C3P0 is an easy-to-use library for augmenting traditional (DriverManager-based) JDBC drivers with JNDI-bindable DataSources, including DataSources that implement Connection and Statement Pooling, as described by the jdbc3 spec and jdbc2 std extension.

CXF java.net.SocketTimeoutException: Read timed out

CXF java.net.SocketTimeoutException: Read timed out

This exception happens, when invoking the client and it takes 50-60 seconds after that  we get java.net.SocketTimeoutException: Read timed out, following are the stacktrace

Caused by: org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage
(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:171)
... 26 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)

This article explains about how to fix this exception in CXF way

BoneCP Connection Pooling Example

BoneCP Connection Pooling Example

BoneCP Connection Pooling Example exaplains about how to create and configure a Connection pool using BoneCP Datasource

Creating and establishing a database connections are relatively very expensive because of establishing a network connection, initializng database session, authorization in the back end database etc.

Due to this issues, it is good practice to use a connection pool in your applications in order to increase the performance and scalability. By using Connection Pool, you can re-use already existing connections and prepared statements, so that you can avoid the cost of establishing the connection.

BoneCP is a fast, free, open-source, Java database connection pool (JDBC Pool) library. If you are familiar with C3P0 and DBCP then you already know what this means. For the rest, this is a library that will manage a database connection for you to get faster database access in your application

Generate Class Diagram Using Eclipse

Generate Class Diagram Using Eclipse

Generate Class Diagram Using Eclipse explains step by step details of installing and configuring ObjectAid plugin with eclipse, this plugin will automate the generation of Class Diagram and Sequence Diagram from java source code.

You need to remember one thing that for generating Sequence Diagram, you need a valid licence. But for generating Class Diagram, it is free.

ObjectAid UML Explorer is an agile and lightweight code visualization tool for the Eclipse IDE.

It shows your Java source code and libraries in live UML class and sequence diagrams that automatically update as your code changes.

Hibernate JPA One To One Relation Mapping Example

Hibernate JPA One To One Relation Mapping Example

Hibernate JPA One To One Relation Mapping Example explains about how to implement a One To One relationship by using Hibernate JPA

Java Persistence API (JPA) is a standard interface which wraps different ORM tools such as  Hibernate, EclipseLink, OpenJPA etc. ie; you can able to change Hibernate implementation to EclipseLink implementation without changing the code base.

one-to-one entity relationship, each record of an entity have single records in other associated entity

On this standalone One To One Mapping Example, we are using Java Persistence (JPA) With MySQL Database. If you want to configure Hibernate JPA With other Databases, you can check below table

Hibernate JPA One To Many Relation Mapping Example

Hibernate JPA One To Many Relation Mapping Example

Hibernate JPA One To Many Relation Mapping Example explains about how to implement a One To Many relationship by using Hibernate JPA

Java Persistence API (JPA) is a standard interface which wraps different ORM tools such as  Hibernate, EclipseLink, OpenJPA etc. ie; you can able to change Hibernate implementation to EclipseLink implementation without changing the code base.

one-to-many entity relationship, each record of an entity have multiple records in other associated entity

On this standalone One To Many Mapping Example, we are using Java Persistence (JPA) With MySQL Database. If you want to configure Hibernate JPA With other Databases, you can check below table

Hibernate JPA Many To One Relation Mapping Example

Hibernate JPA Many To One Relation Mapping Example

Hibernate JPA Many To One Relation Mapping Example explains about how to implement a Many To One relationship by using Hibernate JPA

Java Persistence API (JPA) is a standard interface which wraps different ORM tools such as  Hibernate, EclipseLink, OpenJPA etc. ie; you can able to change Hibernate implementation to EclipseLink implementation without changing the code base.

many-to-one entity relationship, multiple records of an entity have single record in other associated entity

On this standalone Many To One Mapping Example, we are using Java Persistence (JPA) With MySQL Database. If you want to configure Hibernate JPA With other Databases, you can check below table