Sunday, March 29, 2015

How to create Bar Code in java (using aspose and itext) ?

Using aspose API.

For creating a Bar Code is very simple in java using aspose apis. We can use “aspose-barcode-5.4.2-jdk15.jar” for this.


Thursday, March 26, 2015

How to create a Captcha in java?

Creating a captach in java is nothing but converting some random number or character in Image form in Servlet and send it to back as response in form of image to browser.

testCaptcha.jsp



Monday, March 23, 2015

How to connect DB2 database in java?

We have to follow 6 steps to play with DB2 database in java jdbc.

Note: We have use “db2jcc_license_cu-version.jar” and “db2jcc-version.jar” ex- “db2jcc_license_cu-1.0.jar” and “db2jcc-1.0.jar”

Step 1:  Create table in database

CREATE TABLE USER_DETAILS (
USER_ID INTEGER,
USER_NAME VARCHAR(50) NOT NULL,
PASSWORD VARCHAR(50) NOT NULL,
PRIMARY KEY(USER_ID)
)

How to connect Oracle database in java?

We have to follow 6 steps to play with Oracle database in java jdbc.

Note: We have use “ojdbc-version.jar” ex- ojdbc14.jar

Step 1:  Create table in database
CREATE TABLE USER_DETAILS (
            USER_ID NUMBER(5) NOT NULL,
            USER_NAME VARCHAR2(50) NOT NULL,
            PASSWORD VARCHAR2(50) NOT NULL,
) ;

How to connect MySql database in java ?

We have to follow 6 steps to play with MySql database in java jdbc.

Note: We have use “mysql-connector-java-version-bin.jar” ex- mysql-connector-java-5.0.3-bin.jar

Step 1:  Create table in database
CREATE TABLE ‘USER_DETAILS’ (
            ‘USER_ID’ INT(5) NOT NULL,
            ‘USER_NAME’ VARCHAR(50) NOT NULL,
            ‘PASSWORD’ VARCHAR(50) NOT NULL,
            PRIMARY KEY(‘USER_ID’)
) ;

How to create Singleton class in java?

Step 1: Create Class “SingleObject.java”
Step 2: Create a private constructor so no one can instantiate  this class.
Step 3: Create the static method getInstance and this will return the object of SingleObject class.
Step 4: Create client program and call this static method of SingleObject class this method will return the same object each time.
Step 5: We can verify the the singleton behavior by hashCode. The hasCode is same for both object.