Sunday, 27 October 2024

Program to implement an interactive deposit service using JDBC programming model.



 Advanced Java: 05

Q.1 Explain about getConnection() method in Driver-Manager.?
  • getConnection() is a JDBC API method (Library Method)
  • It belongs to java.sql.DriverManager class.
  • It is a static method, so it is being called by class name. like DriverManager.getConnection()
  • This method takes 3 Arguments.1. Database URL: Address of the database server. 2. Username. 3. Password.
  • This method throws java.sql.SQLException if anything goes wrong while establishing connection with the database server.
  • This method is factory method: Inside a method also an object is going to be created and send reference of it to the connection interface.
  • This method provides database connection to a JDBC client.
Q.2 What is Port number? Please explain with example.
  • Consider a scenario where you want to book a railway ticket manually, so what is the first thing he must know is the railway station address he must know. Similarly, Server IP address reach to server machine. accordingly, getConnection() method connect us to the server.
  • As we know on railway station there are several counters for each one like ladies there is sperate counter, senior citizen there is a separate counter, in all general there is a separate counter. accordingly, the counter can work and proceed the task. 
  • So counter number is nothing but port number. port number is unique number on server. MySQL 3306 is port number.
Q.3 What is the meaning of D:\> java DepositApplication
  • java command given to operating system (OS) then OS calls the JVM, It's JVM duty to load DepositeApplication.class file into memory.
  • Now, how can JVM know where this file is located? It knows through classpath. SET Classpath=""
  • Note: Without installing MySQL driver, you cannot connect with database server. (mysql-connector-java 8.0.19)
  • d:/> SET CLASSPATH=.; D:\mysql-connector-java 8.0.19
  • Classpath is an environment variable used by JVM to locate class file.
Q.4 Explain about executeUpdate() method?
  • executeUpdate() is a JDBC API method.
  • It belongs to java.sql.Statement interface object.
  • In real time projects 90% of java objects are interface objects only.
  • This method is used to submit INSERT, UPDATE, DELETE SQL statements from the JDBC client to the DBMS.
  • This method returns an integer this number represents the number of records affected in the database a result of that submitted SQL Statement.
Q.5 Write a JDBC Program to implement an interactive deposit service.
  • Our program should ask the user to enter the account number and amount to be deposited.
  • The database status before program execution is as follows.







data structures and algorithms Web Developer

No comments:

Post a Comment