Database coding

Database connection is always required to develop any database oriented application and in this Final Year Project, java is used as the programming language and java has some predefined set of classes, interfaces and few methods that provide the required API to connect to the database. Java has a separate package known as Java.Sql.*, which provides the required methods, classes and interfaces that can be used by the programmer to connect to the desired database.

In general a bridge is established between the database tier and the business logic tier such that the database updates are maintained on track at the programming side and vice versa. There is a separate sequence that should be used to connect to the database from the java programming side and the sequence is like, first a Connection to the database should be established and this can be done using the Connection object. Once the connection is established successfully, now the required drivers should be set and this can be done using the DriverManager object and once the drivers are ready, the required database operations can be initiated.

All these objects can be created using the default constructer provided with the package API and once these objects are created a separate instance is created to these objects for the data communication. Always a connection is established with proper authentication mechanism and as the SQL is used as the database here, the corresponding SQL username and password are passed as the URL string along with the connection object and if the set of these login credentials are valid, then only the required database connection is established.

Now the required SQL statements can initiated using the Statement object and once the statement object is created, the queries to the database can be passed using this instance of the statement object. In general few exceptions are thrown across this object creation process and they can be handled using the try and catch blocks as defined in the code, that can be seen in the Appendix section.

A separate class is created to handle the database section for this project named ConnectionDB and an instance of this class is created when required. The main purpose this database coding is to maintain the corresponding secret keys of users and the detailed coding done for the database connection is shown in the coding part given in the appendix section Database coding. 

This Paper is written & submitted by Vamshidhar A.