Most of the projects require connecting to a database, the basic steps involved in connecting to a database using JDBC are:

  1. Loading the appropriate driver,
  2. Establishing a connection to the database,
  3. Executing the SQL queries using objects of Statement, PreparedStatement, etc., and
  4. Using the ResultSet object and closing the connection.

All these steps excluding the first step appears to have some purpose and can be understood intuitively. Loading of the driver can be explained as the process of loading the driver class into the memory for using its functionality during the execution process.

The different ways by which we can load a JDBC driver are illustrated:

Read the rest of this entry »

N-queens problem is the generalization of classic 8-queens puzzle (or problem). In N-queens problem, ‘N’ number of queens are to be placed onto a NxN square board (or chessboard), such that no two queens are attacking each other.The solution presented here uses the backtracking approach to solve the N-queens problem.

Read the rest of this entry »

We often come across a client-server architecture, it consists of a service requester machine called client and service provider machine called server. The services are exchanged between these machines using simple message passing. The message passing is of two kinds, synchronous and asynchronous. In asynchronous message passing, the machines exchange messages without any predefined order. In synchronous message passing, the machines exchange messages with a predefined order and time sequences.

Java SE provides us with all things required to communicate messages between machines. Below is the program which performs synchronous message passing between machines.

Read the rest of this entry »

Recently, I had to work on Eclipse for writing Servlet and JSP programs which connects to the MySQL database. I want to configure Eclipse to use Apache Tomcat as server and connects to MySQL database using Servlet program so, I googled it to find what to do as many of them does, but I haven’t found any resource which provides straight forward guide to fulfill my requirement.

After doing some experimental things i have understood the procedure of configuring it so thought of putting a post about it. By the end of the following steps you will be able to configure your eclipse to run Servlet and JSP programs to connect to the MySQL database.

  1. Install MySQL Database.
  2. Install Apache Tomcat.
  3. Install Eclipse IDE for Java EE Developers.
  4. Check whether MySQL is properly installed and running on the system by following below steps:
    • Open terminal or command prompt.
    • Enter “mysql -u root -p” (Here the username is root).
    • Enter the password when prompted.
    • Now create a database using “CREATE DATABASE EXAMPLE”(Here EXAMPLE is the name of database).
    • Select the database using “USE EXAMPLE”.
    • Create the tables according the required schema.

    Read the rest of this entry »

This applet program takes an Infix expression and converts it into an Post-fix expression.
Remember to give the Infix expression like this “a+b”, but not with the numbers like this “2+4″.

Read the rest of this entry »

Blog Stats

  • 7,337 hits

My tweets

Follow me on twitter
Follow

Get every new post delivered to your Inbox.