There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
- Load and register the driver
- Establish connection
- Creating statement object
- Execute the statement
- Closing the connection
- Load and register the driver
For registering the driver we load the driver class using the name forName() method. This method loads the class which is mentioned as parameter.
Class.forName(“com.mysql.jdbc.Driver"); // class.forName load the Driver class
- Establishing the Connection:
For establishing connection with database static method called getConnection () is activated which is present in DriverManagerClass it has three arguments of string type URL, username and password.
DriverManager.getConnection (“jdbc:mysql://localhost:3306 Employee”,"root","root");
URL contains JDBC (main protocol): MySQL (sub protocol for mySql)://localhost:3306(sub name for mySql(host:prot)/Employee(database) when this method returns an connection object that is
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Employee","root","root");
- Creating statement object
For creating statement object a method is called createStatement() which is called present connection interface.
con.createStatement();
which returns the object with no argument like
Statement st= con.createStatement();
- Executing Queries
For executing queries there are different methods in statement interface by retrieving records and updating records. For fetching queries we call method like executeQuery (string qry) by taking string as parameter.
st.executeQuery ("Select * from Employee");
This returns the object as resultset object
Resultset rs= st.executeQuery ("Select * from Employee”);
// once executeQuery() executes the query and stores the records in to ResultSet object.
- Close connection
18 Responses
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector.
It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
The steps are Load and register the driver , Establish connection , Creating statement object , Execute the statement ,
Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
How to connect Databases using JDBC?
JDBC (Java Database Connectivity) is the Java API that manages connecting to a database, issuing queries and commands, and handling result sets obtained from the database.
There are steps for database connectivity. Before proceeding, you need to have a MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
For connectivity of database we need to have
– MySQL connector.: It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Steps for database connectivity:
1. Load and register the driver
2. Establish connection
3. Creating statement object
4. Execute the statement
5. Closing the connection
There are steps for connectivity of database.You need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
Here are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
How to connect Database using JDBC?
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
1. Load and register the driver
2. Establish connection
3. Creating statement object
4. Execute the statement
5. Closing the connection
1. Load and register the driver
For registering the driver we load the driver class using the name forName() method. This method loads the class which is mentioned as parameter.
1.Establishing the Connection:
2. Creating statement object
3. Executing Queries
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
1. Load and register the driver
2. Establish connection
3. Creating statement object
4. Execute the statement
5. Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
1. Load and register the driver
2. Establish connection
3. Creating statement object
4. Execute the statement
5. Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
How to connect Database using JDBC?
There are steps for the connectivity of the database. Before proceeding, you need to have a MySQL connector. It can be downloaded from the Download MySQL connector Jar and add it as a build path by adding the Selenium web driver jar.
Below are the steps:
> Load and register the driver
> Establish connection
> Creating statement object
> Execute the statement
> Closing the connection
How to connect Database using JDBC?
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
1. Load and register the driver
2. Establish connection
3. Creating statement object
4. Execute the statement
5. Closing the connection
Load and register the driver
For registering the driver we load the driver class using the name forName() method. This method loads the class which is mentioned as parameter.
Class.forName(“com.mysql.jdbc.Driver”);
//class.forName load the Driver class
Establishing the Connection:
For establishing connection with database static method called getConnection () is activated which is present in DriverManagerClass it has three arguments of string type URL, username and password.
DriverManager.getConnection (“jdbc:mysql://localhost:3306 Employee”,”root”,”root”);
URL contains JDBC (main protocol): MySQL (sub protocol for mySql)://localhost:3306(sub name for mySql(host:prot)/Employee(database) when this method returns an connection object that is
Connection
con=DriverManger.getConnection(“jdbc:mysql://localhost:3306/Employee”,”root”,”root”);
Creating statement object
For creating statement object a method is called createStatement() which is called present connection interface.
Con.createSatatement();
which returns the object with no argument like
Statement st=con.createStatement();
Executing Queries
For executing queries there are different methods in statement interface by retrieving records and updating records. For fetching queries we call method like executeQuery (string qry) by taking string as parameter.
st.executeQuery (Select*from Emplyee”);
This returns the object as resultset object
Resultset rs=st.executeQuery(“Select*from Employee”);
// once executeQuery() executes the query and stores the records in to ResultSet object.
Close connection
There are steps for connectivity of database. MySQL connector needs to be installed. The steps are: load and register the driver, establish connection, creating statement object, execute the statement and closing the connection.
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
The steps are listed below:
Load and register the driver
Establish connection
Creating statement object
Execute the statement
Closing the connection
Load and register the driver
For registering the driver we load the driver class using the name forName() method. This method loads the class which is mentioned as parameter.
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
* Load and register the driver
* Establish connection
* Creating statement object
* Execute the statement
* Closing the connection
There are steps for connectivity of database. Before proceeding, you need to have MySQL connector. It can be downloaded from Download MySQL connector Jar and add it as a build path by adding Selenium web driver jar.
Below are the steps:
1.Load and register the driver
2.Establish connection
3.Creating statement object
4.Execute the statement
5.Closing the connection