NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Database class -

This class is used to connect to the Database and get a Connection class object which is used to execute queries on the database.
The properties of the database are passed in the constructor of the Database class. getConnection() method in the Database class returns a Connection class
object when the connection to the database is established. All the operations on the database can now be executed using the Connection class object.

DatabaseUtil class -
The static variable database (private static Database database = null;) is initialised when the class loads for the first time.
The Connection object to the database can be used using database.getConnection() method.

DatabaseUtil methods -



void storeCustomerDetailsToDb(CustomerDetails customerDetails);

The stored procedure INSERT_USER_DETAILS is used to insert a row in the table .Stored procedure helps in simplifying the insert operation.
An alternatice to using stored procedure is to use the SQL command(INSERT INTO user_info values (user_idx,emailx,mobilex,namex,account_numberx)) everytime we need to insert a row.


CREATE PROCEDURE INSERT_USER_DETAILS(IN user_idx VARCHAR(100),
IN emailx VARCHAR(100),
IN mobilex VARCHAR(100),
IN namex VARCHAR(100),
IN account_numberx VARCHAR(100))
BEGIN
INSERT INTO user_info values (user_idx,emailx,mobilex,namex,account_numberx);
END;


This method is used to insert a row in the user_info table by calling the Stored procedure INSERT_USER_DETAILS. The values to pass to the stored procedure is taken from the customerDetails object.

callableStatement = database.getCallableStatement("{call INSERT_USER_DETAILS(?,?,?,?,?)}");

CallableStatement class is an interface which is used to execute stored procedure.
Callable statement description(read it in brief, will take 5 minutes) - http://tutorials.jenkov.com/jdbc/callablestatement.html


callableStatement.setString(1, customerDetails.getCustomerUserId());
callableStatement.setString(2, customerDetails.getCustomerEmailId());
callableStatement.setString(3, customerDetails.getCustomerMobileNumber());
callableStatement.setString(4, customerDetails.getCustomerName());
callableStatement.setString(5, customerDetails.getCustomerAccountNumber());

The above lines are passing the values to the stored procedure. When we call (ResultSet resultSet = callableStatement.executeQuery()) , the callable statement is executed and the row in inserted in the table.


All the other stored procedure work in the same way.





DAO classes -


Go through this link - https://www.tutorialspoint.com/design_pattern/data_access_object_pattern.htm

The class BankAccountDAO is the interface as mentioned in the DAO design pattern.
The class BankAccountDAOImplementation is the class which implements this interface.

The use of DAO design pattern is to separate low level data accessing API from high level service.
For example in our case we need to call BankAccountDaoImplementation.getBankAccount(accountNumber) to get the bank account details which is high level service for us. But the low level service to get the bank account details is DatabaseUtil.getBankAccountDetailsFromDB(accountNumber).

So we could have called the method DatabaseUtil.getBankAccountDetailsFromDB(accountNumber) directly, but using the DAO design pattern simplifies the usage.

Same explanation for CustomerDaoImplementation.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.