Archive for the ‘java’ Category

Creating And Running JSF Project

Sunday, August 2nd, 2009

These notes follow on from my previous posting regarding JavaServer Faces Technology – JSF. In this post, I’m going to quickly outline the necessary steps for getting a very simple JSF project running within Galileo.

First, you’ll need to download Mojarra and unpack it somewhere.

Go to the Java EE perspective and create a new project to get the “New Project” wizard to appear. Expand out “Web” and select “Dynamic Web Project”. Give the project a name.

The “Target Runtime” should be Apache Tomcat v6.0, The Dynamic web module version should be 2.5 and select JavaServer Faces v1.2 Project as your configuration option.

Choose “Next” for the Source folders option and “Next” for the Web Module settings.

For the JSF Implementation Library settings, click on the “Manage Libraries” link (it’s the icon on the right, just below the “Type” dropdown list), Select “New”, create a name (e.g. “Mojarra”) and check the System Library checkbox. Select OK and then highlight the library you just created and select “Add JARs”. Navigate to the folder where you unpacked Mojarra and go to its lib folder. Select both jsf-impl.jar and jsf-api.jar and then select “Open”.

Both JARs should be visible under the library you created. Select “OK” and now check the library you just created and select “Finish”. You should now be ready to start coding.

To create a simple JSF example project:

1. Right-click on your Java Resources:src folder and select New > Other. Expand out “General” and select “File” and select “Next”. If it asks you to select a “parent folder”, just select the src folder for the project you just created. The file should be called messages.properties. In that file, add a line: greeting=JSF is working and save the file.

2. in WebContent/WEB-INF/web.xml, find the <servlet-mapping> and make sure it looks like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

3. Right-click on WebContent and select “New” and “JSP”. Name it “index.jsp”. You should have a basic html template page.
In the body of the template, paste in:
<jsp:forward page=”/faces/greeting.jsf” />

4. Create a folder called “faces” under “WebContent”

5. Create a New JSP file inside the “faces” folder. Call it greeting.jsp (note the file extension is jsp, *not* jsf)

6. And in between the body tags, paste in:
<f:view>
<f:loadBundle basename=”messages” var=”message”/>
<p><h:outputText value=”#{message.greeting}” /></p>
</f:view>

7. Run it!!

JavaServer Faces Technology – JSF

Saturday, June 27th, 2009

JavaServer Faces technology is a server-side user interface component framework for Java technology-based web applications, its includes

  • A set of APIs for representing UI components and managing their state, handling events and input validation, defining page navigation, supporting internationalization and accessibility and providing extensibility for all these features.
  • A JavaServer Pages (JSP) custom tag library for expressing JavaServer Faces UI components within a JSP page and for wiring components to server-side objects

The well-defined programming model and tag libraries significantly ease the burden of building and maintaining web applications with server-side UIs. Here is the model:

One of the greatest advantages of JavaServer Faces technology is that it offers a clean separation between behavior and presentation. Web applications built using JSP technology achieve this separation in part. However, a JSP application cannot map HTTP requests to component-specific event handling nor manage UI elements as stateful objects on the server, as a JavaServer Faces application can. JavaServer Faces technology allows you to build web applications that implement the finer-grained separation of behavior and presentation that is traditionally offered by client-side UI architectures. The separation of logic from presentation also allows each member of a web application development team to focus on his or her piece of the development process, and it provides a simple programming model to link the pieces.

Another important goal of JavaServer Faces technology is to leverage familiar UI-component and web-tier concepts without limiting you to a particular scripting technology or markup language. Although JavaServer Faces technology includes a JSP custom tag library for representing components on a JSP page, the JavaServer Faces technology APIs are layered directly on top of the Servlet API.

Most importantly, JavaServer Faces technology provides a rich architecture for managing component state, processing component data, validating user input, and handling events.

For the most part, a JavaServer Faces application is like any other Java web application. A typical JavaServer Faces application includes the following pieces:

  1. A set of JSP pages (although you are not limited to using JSP pages as your presentation technology)
  2. A set of backing beans, which are JavaBeans components that define properties and functions for UI components on a page
  3. An application configuration resource file, which defines page navigation rules and configures beans and other custom objects, such as custom components
  4. A deployment descriptor (a web.xml file)
  5. Possibly a set of custom objects created by the application developer. These objects might include custom components, validators, converters, or listeners
  6. A set of custom tags for representing custom objects on the page

Java Tips: Class

Monday, May 18th, 2009

In object-oriented programming, a class is a programming language construct that is used as a blueprint to create objects. This blueprint includes attributes and methods that the created objects all share.

A class can represents a person, place, or thing as an abstraction of a concept within a computer program. Fundamentally, it encapsulates the state and behavior of that which it conceptually represents. It encapsulates state through data placeholders called member variables (or instance variables). It encapsulates behavior through reusable code called methods.

There is some rules associated with declaring classes in a source file [SCJP 1.6 Study Guide]:

  1. There can only one public class per source code file.
  2. If there is a public class in a file, the name of the file must match with the name of the public class.
  3. If the class is part of the package, the package statements must be the first line inte source code file before import statement that maybe present.
  4. If there are import statement, they must written between the package statement and the class declaration.
  5. A source code file can have more than one nonpublic class.

The following code is the bare-bones class declaration:

class MyFirstClass() {
  //.......
}

Ok, lets start to make a hello world class :)

public class MyHelloWorld() {
  private String greet = &quot;Ehlo World&quot;;
  public void says() {
    System.out.println(greet);
  }
}

Oracle Buys Sun

Monday, April 20th, 2009

On April 20, 2009, Oracle announced it has entered into an agreement to acquire Sun Microsystems (Sun). The proposed transaction is subject to Sun stockholder approval, certain regulatory approvals and customary closing conditions. Until the deal closes, each company will continue to operate independently, and it is business as usual.

The acquisition combines best-in-class enterprise software and mission-critical computing systems. Oracle plans to engineer and deliver an integrated system—applications to disk—where all the pieces fit and work together so customers do not have to do it themselves. Customers benefit as their system integration costs go down while system performance, reliability and security go up.

taken from:

  1. http://www.oracle.com/index.html
  2. http://www.sun.com/third-party/global/oracle/index.jsp

Java Tips: Identifiers

Friday, April 10th, 2009

On java programming language, the name of classes, variables, methods called an identifier. Java has some rules about identifiers so that identifiers are legal for use.

Technically, legal identifiers must be composed of only Unicode Characters, number, curency character, and connecting character (like underscores).

Then, here are the rules you do need to know:

  1. Identifiers must start with letter, a curency character ($), or a connecting character. It is can’t start with a number.
  2. After the first character above, identifiers can contain any combination of  Unicode Characters, number, curency character, and connecting character.
  3. There is no limit to the number of characters an identifiers can contain.
  4. Can’t use java keywords as an identifiers
  5. Like the java programming languange habbit, the identifiers are case-sensitive.

Happy Coding… :)

Java Tips: Generic Type

Thursday, March 19th, 2009

When work on Java 5 environment or above, we usually found a suppress warning for our collection definition (List, ArrayList, Vector, HashMap, etc…). Different with Java 1.4 environment, its free for us to define HashMap contain with many type of object as its key and its value. On Java 5 we still can do that but it is caused warning when we compile the source. So we need to parameterized its HashMap.

With parameterized its HashMap, we can safe our code from any object missmatch. It’s mean that we prepare a specific bucket and then fill its bucket with apropriate contents. As example, the code below caused warning:

...
HashMap map = new HashMap();
...

Better we parameterized that HashMap with specific data type as a control for us when we assign value on it. For example we decide that the key of the HashMap is String and the value is String too, then the code should be like this:

...
HashMap map = new HashMap();
map.put(&quot;one&quot;, &quot;Value is ONE&quot;);
map.put(&quot;two&quot;, &quot;Value is TWO&quot;);
// map.put(&quot;three&quot;, 3); // its return an error
...

So when we want to access its value we shouldn’t wrong about the data type.

...
String val = map.get(&quot;one&quot;);
// Integer val = map.get(&quot;one&quot;);
// line code above will cause Error because type missmatch
...

When we don;t know exactly what kind of data type fetched, we can generalized its return as Object. And then, from fetched list we can decide what kind of object and its method contained.

...
// fetching
List result = sess.createQuery(&quot;from Event&quot;).list();
// Displaying
for (Object o : result) {
    if (o instanceof Event) {
        event = (Event) o;
        System.out.println(event.getTitle());
    }
}
...

Happy coding ;)

update for HashMap looping:

...
Iterator iter = hashMap.keySet().iterator();

while (iter.hasNext()) {
    String key = iter.next();
    String value = hashMap.get(key);
    System.out.println(&quot;Key =&quot;+key+&quot;\n Value&quot;+value)
}
...

Java Micro Edition

Wednesday, February 11th, 2009

Most of you mobile programmer should know about this widely used technology, technology for mobile application that introduced by Sun Microsystem. Java Micro Edition also called Java ME, one of three platforms that designed and created by Sun Microsystem in order to deal with the constraint associated with building application for small device.

Java ME allows java applications running on small devices that have some of limitations, there is memory, display, and power capacity limitations. This technology consist of three elements:

  1. Configuration, element that provides the most basic set of libraries and virtual machine capabilities for a broad range of devices. This configuration divided into two base configuration, one to fit small mobile devices (like handphone) called Connected Limited Device Configuration – CLDC, the other is to be targeted towards more capable mobile devices (like smart phones and PDA) called Connected Device Configuration – CDC.
  2. Profile, element that consist of set of APIs that support a narrower range of devices. Each Configuration have own Profile, for CLDC the profile is Mobile Information Device Profile – MIDP. Otherwise, for CDC defined three different kind of Profile, Foundation Profile, Personal Basis Profile, And Personal Profile. Each profile has different set of optional packages.
  3. Optional Package, element that consist of a set technology-specific APIs.

Java Platform

As of 22 December 2006, the Java ME source code is licensed under the GNU General Public License, and is released under the project name phoneME.

Database Connection Pool [part-3]

Friday, January 16th, 2009

Melanjutkan postingan saya sebelumnya tentang Database Connection Pool di sono dan di sini, dan sebagai part terakhir dari trilogy Database Connection Pool *halah, kaya film aja* maka kali ini saya akan paparkan mengenai pembuatan java class yang mampu menangani Database Connection Pool seperti yang dilakukan oleh Application Server atau Web Container.

Untuk bisa malakukan Database Connection Pooling, kita butuh JDBC Wrapper Classes. Wrapper classes ini terdiri dari 3 buah class yang memiliki fungsi sendiri-sendiri. Tiga class tersebut adalah:

  1. Connection Driver Class. Class ini mengimplementasikan java.sql.driver yang menyediakan method untuk me-load driver dan membuat koneksi database.
  2. Connection Pool Class. Class ini menghandle manajemen Pool koneksi. Ketika method getConnection dipanggil, maka Class ini akan mencari Koneksi yang tersedia dalam Pool, jika tidak ada maka akan dibuatkan koneksi baru dan dimasukkan dalam pool. Dalam Class ini juga ada Connection Reaper yang berfungsi untuk melakukan penghapusan koneksi yang sudah tidak terpakai.
  3. Connection Class. Class ini menimplementasikan java.sql.Connection yang merepresentasikan JDBC Connection dalam Connection Pool ini. Class ini memberikan state pada koneksi yang ada, apakah sedang digunakan atau tidak.

Cara penggunaan dari tiga buah class di atas sangat mudah, kita tinggal buat satu Class untuk handle buka koneksi seperti dibawah ini:

package modules;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
* @author satria.permana
*
*/
public class PgInt {
    String foo  = &quot;Not Connected&quot;;
    String spbCode = &quot;Not Connected&quot;;
    String spbDescription = &quot;Not Connected&quot;;
    Connection connection = null;

    public PgInt() {
        try {
            new pool.JDCConnectionDriver(
                &quot;org.postgresql.Driver&quot;,
                &quot;jdbc:postgresql://localhost:5432/dbname&quot;,
                &quot;dbuser&quot;,
                &quot;dbpassword&quot;);
        } catch (Exception e) {
        }
    }

    public Connection getConnection() throws SQLException {
        connection = DriverManager.getConnection(&quot;jdbc:jdc:jdcpool&quot;);
        return connection;
    }
}

setelah itu kita tinggal panggil class tersebut di blok-blok kode kita lainnya. Jika kita ingin panggil dari halaman JSP, mungkin contoh nya seperti ini:

&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;

&lt;%@page import=&quot;modules.PgInt&quot;%&gt;
&lt;%@page import=&quot;java.sql.Connection&quot;%&gt;
&lt;%@page import=&quot;pool.JDCConnection&quot;%&gt;

&lt;html&gt;
&lt;head&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
    &lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;%
PgInt pg = new PgInt();
JDCConnection conn1 = null, conn2 = null;
conn1 = (JDCConnection) pg.getConnection();
out.println(
    &quot;CONN1&quot; + conn1 + &quot;&quot;);
conn1.close();
conn2 = (JDCConnection) pg.getConnection();
conn2.close();
out.println(
    &quot;CONN2&quot; + conn2 + &quot;&quot;);
%&gt;

&lt;/body&gt;
&lt;/html&gt;

Oke selamat mencoba!! :)

Sumber: java.sun.com

Database Connection Pool [part-2]

Sunday, December 28th, 2008

Dalam pemrograman Java, salah satu cara untuk melakukan teknik Database Connection Pooling adalah dengan memanfaatkan konfigurasi server yang kita pakai sebagai host dari aplikasi kita, baik itu application server maupun web container. Nah, sbagai lanjutan dari [part 1], kali ini saia akan coba berbagi tentang bagaimana cara kita mengkonfigurasi server kita agar bisa mendukung teknik Database Connection Pooling ini.

Sebelum masuk ke langkah-langkah konfigurasi, ada baiknya kita tau apa-apa saja yang dibutuhkan untuk proses pengkonfigurasian ini antara lain:

  1. Application Server atau Web Container – saia menggunakan Apache Tomcat 6 sebagai web container
  2. Database yang sudah support Connection Pooling (MySQL, PostgreSQL, Oracle) – saia menggunakan PostgreSQL 8.2
  3. Driver JDBC dari database yang kita gunakan (JDBC v2 or higher) – saia menggunakan postgresql-8.2-509.jdbc3.jar
  4. mm… kira-kira apalagi ya..?? tau ah.. ntar kalo kurang tambahin ndiri yak!! :D

Saia asumsikan bahwa Tomcat 6 dan PostgreSQL 8.2 sudah terinstall di Ubuntu saia. OK sekarang masuk ke langkah-langkah konfigurasi:

  1. Kita letakkan driver JDBC kita ke dalam folder lib yang ada di tempat Tomcat 6 saia terinstall. Berikut ini adalah path dimana Tomcat 6 saia terinstall : /home/satria/Application/apache-tomcat-6.0.14. Jadi berikut adalah path lengkap dari driver JDBC saia: /home/satria/Application/apache-tomcat-6.0.14/lib/postgresql-8.2-509.jdbc3.jar
  2. Setelah itu kita edit file server.xml yang ada di /home/satria/Application/apache-tomcat-6.0.14/conf/server.xml tujuannya adalah supaya environment dari Tomcat Server ini bisa menangani Connection Pool – bahasa gampangnya meregister resource Connection Pool ke Tomcat Server. Caranya adalah dengan menyisipkan tag <resource> diantara tag <context>. Berikut adalah contoh potongan konfigurasinya:
    &lt;Context docBase=&quot;__DBPooling5&quot; path=&quot;/__DBPooling5&quot; reloadable=&quot;true&quot; crossContext=&quot;true&quot;&gt;
        &lt;Resource
            auth=&quot;Container&quot;
            driverClassName=&quot;org.postgresql.Driver&quot;
            maxActive=&quot;100&quot;
            maxIdle=&quot;30&quot;
            maxWait=&quot;10000&quot;
            name=&quot;db_xxxxxx&quot;
            password=&quot;dbapassword&quot;
            type=&quot;javax.sql.DataSource&quot;
            url=&quot;jdbc:postgresql://localhost:5432/db_xxxxxx_test&quot;
        username=&quot;dbauser&quot; /&gt;
    &lt;/Context&gt;
    

    Mungkin beberapa yang perlu diperhatikan antara lain tag-property driverClassName silahkan disesuaikan dengan driver database yang digunakan, url silahkan disesuaikan dengan url database yang dipakai oleh aplikasi, username dan password silahkan disesuaikan dengan username dan password yang terdaftar pada database yang digunakan.

  3. Setelah itu kita konfigurasi file web.xml yang juga ada di folder yang sama dengan file server.xml . Berikut adalah contoh potongan tag
    &lt;resource-ref&gt;
        &lt;description&gt;postgreSQL Datasource&lt;/description&gt;
        &lt;res-ref-name&gt;db_xxxxxx&lt;/res-ref-name&gt;
        &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
        &lt;res-auth&gt;Container&lt;/res-auth&gt;
    &lt;/resource-ref&gt;
    
  4. Jika sudah selesai semua kita restart service Tomcat nya.
  5. Sekarang Tomcat kita sudah support Database Connection Pool, tinggal kita lakukan pengkodean untuk mengakses resource Connection Pool ini.

Pada contoh kali ini, saya membuat sebuah class yang menangani permintaan koneksi dan pengembalian koneksi ke Pool dengan nama PgPoolTomcat.java

package modules;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

/**
* @author satria.permana
*
*/
public class PgPoolTomcat {
    DataSource ds = null;

    public PgPoolTomcat() {
        init();
    }

    private void init() {
        try {
            Context ctx = new InitialContext();
            if (ctx == null) {
                throw new Exception(&quot;Boom - No Context&quot;);
            }
            ds = (DataSource) ctx.lookup(&quot;java:comp/env/db_xxxxxx&quot;);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Connection getConnection() {
        Connection conn = null;
        if (ds != null) {
            try {
                conn = ds.getConnection();
            } catch(SQLException sqlE) {
            }
        }
        return conn;
    }
}

Silahkan simpan file ini di folder source web-project Anda pada package modules. Selanjutnya kita buat sebuah halaman JSP yang memanfaatkan Class PgPoolTomcat.java ini untuk melakukan request koneksi dari Pool. Berikut adalah contoh file JSP :

&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=UTF-8&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;%@page import=&quot;java.sql.Connection&quot;%&gt;
&lt;%@page import=&quot;pool.JDCConnection&quot;%&gt;
&lt;%@page import=&quot;modules.PgPoolTomcat&quot;%&gt;
&lt;%@page import=&quot;java.sql.Statement&quot;%&gt;
&lt;%@page import=&quot;java.sql.ResultSet&quot;%&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
    &lt;title&gt;Insert title here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;%
PgPoolTomcat pg = new PgPoolTomcat();
Connection conn1 = pg.getConnection();
Statement st1 = conn1.createStatement();
// Silahkan sesuaikan query dibawah ini dengan query yang sesuai dengan database Anda
ResultSet rs1 = st1.executeQuery(&quot;SELECT * FROM master_ma.item LIMIT 10&quot;);
while(rs1.next()) {
    out.println(&quot;[] &quot;+conn1+&quot; - &quot; + rs1.getString(&quot;code&quot;) + &quot;&lt;br/&gt;&quot;);
    Statement st2 = conn1.createStatement();
    ResultSet rs2 = st2.executeQuery(&quot;SELECT * FROM master_ma.item LIMIT 1&quot;);
    if (rs2.next()) {
        out.println        (&quot;|| &quot;+conn1+&quot; - &quot; + rs2.getString(&quot;code&quot;) + &quot;&lt;br/&gt;&quot;);
    }
    rs2.close();
    st2.close();
    try {
        Thread.sleep(1000);
    } catch(InterruptedException iE) {
    }
}
conn1.close();
%&gt;
&lt;/body&gt;
&lt;/html&gt;

OK.. kini semua sudah siap, dan sekarang saatnya kita melakukan test terhadap Connection Pool yang sudah kita konfigurasi. Pertama silahkan periksa Server database PostgreSQL apakah sudah berjalan dengan baik, dan pastikan ada atau tidak koneksi yang terbentuk pada saat ini.

pg_service

Setelah itu kita periksa apakah servis Tomcat 6 kita sudah berjalan dengan baik pada port 8080.

tomcat_service

Jika sudah, kini saatnya kita lakukan testing Connection Pool dengan cara mengakses halaman index_tomcat.jsp yang sudah kita buat tadi melalui web browser. Kalau ingin lebih meyakinkan silahkan buka 2 buah browser dan lakukan pengaksesan halaman yang sama secara hampir bersamaan.

index_tomcat

Ketika proses di halaman web masih berlangsung, silahkan periksa resource koneksi yang terjadi pada Server database PostgreSQL melalui perintah ps -ax di console linux. Disana kita akan bisa melihat ada satu resource Connection Pool yang digunakan untuk mengakses database.

service_pg_pooled

Seharusnya koneksi yang dibuat tidak akan muncul sebanyak jumlah client yang melakukan request seperti halnya pada aplikasi biasa yang tidak menerapkan Connection Pooling. Satu resource Connection Pool tersebut akan di-release ketika Server Tomcat atau Server Database kita restart. Jadi dalam hal ini, kita sudah bisa melakukan penghematan resource untuk melakukan buka-tutup koneksi yang “mahal” harganya. Semoga bermafaat.. :)

Database Connection Pool [part-1]

Monday, December 22nd, 2008

Bagi para developer  aplikasi basis data mungkin sudah sering mendengar istilah Connection Pooling atau biasa disebut Pooling. Tapi bagi developer lainnya mungkin istilah tersebut juga sering terdengar, tapi hanya sebatas kulit saja belum sampai kedalam-dalamnya. Ya…, dalam dunia software engineering, Connection Pooling adalah sebuah cache terhadap koneksi database.

Connection Pool ini sebenarnya pertama kali diperkenalkan oleh Microsoft IIS yang kemudian idenya juga dikembangkan oleh vendor-vendor web server lainnya. Ide awal munculnya penggunaan Connection Pooling ini didasari pada besarnya resource yang dibutuhkan ketika satu user / client melakukan pembukaan koneksi, proses transaksi, lalu kemudian penutupan koneksi database. Mungkin jika interaksi aplikasi dengan database tidak terlalu intens, problem ini tidak terlalu kerasa. Namun untuk aplikasi yang basically adalah database-driven sering koneksi ke database problem ini akan sangat-sangat terasa apalagi client yang melakukan koneksi sangat banyak.

Jadi, pada Connection Pooling ini, setelah koneksi database dibuat, koneksi tersebut akan diletakkan di pool dan terus menerus digunakan oleh banyak user. Sehingga setiap ada user atau klien yang butuh koneksi database, tidak perlu membuat koneksi database baru, cukup merequest koneksi yang ada dalam pool tadi. Baru ketika semua koneksi dalam pool sedang digunakan, maka baru dibuat koneksi database yang baru.

connection_pooling

connection_pooling

Connection Pooling umumnya digunakan di aplikasi berbasis web dan aplikasi enterprise dimana penanganan Connection Pool ini ditangani oleh application server atau web container. Sehingga pada masing-masing halaman dynamic-web bisa dilakukan pengkodean untuk melakukan buka-tutup koneksi seperti biasa, tetapi dibalik itu bukanlah buka-tutup koneksi yang dilakukan melainkan request koneksi dan mengembalikan koneksi pada pool setelah selesai digunakan. Untuk bisa menangani Connection Pool, perlu dilakukan konfigurasi pada environtment aplikasi server atau web container.

Selain ditangani oleh aplikasi server atau web container, Connection Pool juga bisa ditangani sendiri secara manual oleh aplikasi yang bersangkutan. Namun untuk bisa membuat sebuah framework yang mampu menangani Connection Pool sangatlah kompleks tapi bukan berarti mustahil. keuntungan dari jenis Connection Pool yang ini adalah bisa dilakukan secara Runtime, karena tidak lagi bergantung pada konfigurasi aplikasi server atau web container lagi, tetapi cukup menggunakan API Framework tersebut.

Jadi untuk para pengembang aplikasi database, mungkin ini adalah salah satu solusi untuk mengatasi masalah membengkaknya resource akibat banyaknya prosesn buka-tutup koneksi database. Semoga bermanfaat… :) Oiya, di postingan selanjutnya saya akan coba berikan contoh pengaplikasian 2 jenis Connection Pool yang sudah saya sebutkan. So.. ditunggu yah…