JDBC Connection steps:
1) Register a database driver: This is done in order to register which type of database drivers going to use.
2) Load database driver: This is done to get the connection object using DriverManager class
DriverManager uses the first two terms of the URL (jdbc:msql) to locate a suitable driver from among those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.
3) Create a statement object using sql query:
PreparedStatement fielStatement = connection.prepareStatement(SQL_STRING);
4) Execute sql statement: This is done using executeQuery() method of PreparedStatement object
ResultSet resultSet = fielStatement.executeQuery();
5) Iterate the ResultSet object to retrieve the data
6) Finally, close the PreparedStatement and Connection object
1) Register a database driver: This is done in order to register which type of database drivers going to use.
2) Load database driver: This is done to get the connection object using DriverManager class
DriverManager uses the first two terms of the URL (jdbc:msql) to locate a suitable driver from among those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.
3) Create a statement object using sql query:
PreparedStatement fielStatement = connection.prepareStatement(SQL_STRING);
4) Execute sql statement: This is done using executeQuery() method of PreparedStatement object
ResultSet resultSet = fielStatement.executeQuery();
5) Iterate the ResultSet object to retrieve the data
6) Finally, close the PreparedStatement and Connection object
No comments:
Post a Comment