Welcome to Java4u

A Single Place for all Java Resources

Looking for something?

Subscribe to this blog!

Receive the latest posts by email.

.Just enter your email below if you want to subscribe!

Email

OAuth 2.0

OAuth 2.0 is an open authorization framework and mainly focuses on authorization flows fand secures access to many well-known web APIs.

Java 8 features

The key features of JDK 8 are Project Lambda (JSR 335), the Nashorn JavaScript Engine, a new Date and Time API (JSR 310), a set of Compact Profiles and the removal of the "permanent generation" from the HotSpot Java Virtual Machine (JVM). A complete list of the new features and capabilities of JDK 8 is available.

Lambda Expression

A lambda expression represents an anonymous function. It comprises of a set of parameters, a lambda operator (->) and a function body.

SOAP vs RESTful

SOAP : Web service use XML messages that follow the Simple Object Access Protocol (SOAP) standard.
RESTful : Web service, often better integrated with HTTP than SOAP-based services are, do not require XML messages or WSDL service–API definitions.

Softwares Engineering / SDLC

Software engineers apply the principles of engineering to the design, development, maintenance, testing, and evaluation of the software and systems that make computers or anything containing software work.

Showing posts with label J2EE. Show all posts
Showing posts with label J2EE. Show all posts

Friday, February 25, 2011

Connection Pooling

Problem with traditional approach Connection Management:

1. This approach is time consuming task, since this is including the time taken for opening the
database session (connection) & closing the database session into request processing time.
2. This approach reduces the availability of the resources (database connections).
3. Decreases our system performances.

Solution to the above problem is given in the form of Connection Pooling.

Q .What is Connection Pooling?

  1. It’s a process of creating and storing database connections into buffer (or) a pool.
  2. A low-Level service offered by the corresponding server is called Connection Pooling.

    Q .What is Connection Pool?

            Set of equal database connection objects, is nothing but Connection Pool.
    BENEFITS:-

    1. In case of Connection Pooling, no need to place any resource allocation logic & de-allocation
    logic in our application.
    2. In this approach, unused connection instances automatically retained (sent back) back to the
    pool.
    3. Retained connection objects are available to other remaining applications i.e.., Connection
    Pooling provides reusable connection objects.
    4. If we use Connection pooling mechanism, in designing of our application than our application
    performance automatically getting increased.

    Q.How to maintain communication with third-party vendor (server) provided Connection Pool
    approach?

            Using DataSource type of object .

    It is an interface from SUN(oracle),which provide a standard abstraction to main communication with
    third-party vendor provided Connection Pool’s.

    By using DataSource interface implementation class object, we are allowed to collect required
    database connection insatances from Connection Pool.

    DataSource is available in (javax.sql.DataSource).

    Q.How to collect the DataSource interface implementation class object ?

    To collect this object, we can use

    • JNDI LookUp.
              -- pulling approach.

    • Resource Dependency Injection (introduced in JAVA EE 5.0).

               -- pushing approach.

               --@Resource annotation.

    Connection Pool contains physical Connection objects.

    Java Application Pool contains logical Connection objects.

    • Pooled Connection: -A Connection object which resides inside the Connection Pool & it directly

    interacts with the Database.

    • Logical Connection:-A Connection instance which is not directly interacting with database.

    When connection.close() is called, there is no relation b/w pooled connection & logical
    connection, but there is a relation b/w database & pooled connection.

    From one-pooled connection, we can obtain only one-single logical connection.

    If we don’t specify connection.close(),(unused connection instances automatically retained back).

    Monday, August 23, 2010

    JDBC

    The JDBC ( Java Database Connectivity) API defines interfaces and classes for writing database applications in Java by making database connections. Using JDBC you can send SQL, PL/SQL statements to almost any relational database. JDBC is a Java API for executing SQL statements and supports basic SQL functionality. It provides RDBMS access by allowing you to embed SQL inside Java code. Because Java can run on a thin client, applets embedded in Web pages can contain downloadable JDBC code to enable remote database access. You will learn how to create a table, insert values into it, query the table, retrieve results, and update the table with the help of a JDBC Program example.

    Although JDBC was designed specifically to provide a Java interface to relational databases, you may find that you need to write Java code to access non-relational databases as well.


    JDBC Architecture


    Java application calls the JDBC library. JDBC loads a driver which talks to the database. We can change database engines without changing database code.