1I USE JDCB
2I use CONNECTION database to make connection
3I create STATEMENT than I use statement to create query
4And run the query and get the RESULT SET
5
6
7Connection = import java.sql.Connection;
8Driver manager = import java.sql.DriverManager;
9Connection connection = DriverManager.getConnection(url, userName, passWord);
10
11Connection String Syntax:
12jdbc:DataBaseType"subprotocal:Host:port:SID
13
14After succesfully created the connect next step is STATEMENT
15
16import java.sql.Statement;
17Statement statement = connection.createStatement();
18
19-We use createStatement() method to create the statement from our connection.
20-The result we get from this type of statement can only move from top to bottom,
21not other way around
22
23Once we have statement we can run the query and get the result to
24ResultSet format
25 import java.sql.ResultSet;
26
27We use the method executeQuery() to execute our queries
28
29ResultSet result = statement.executeQuery("Select * from employees");
1const mysql = require('mysql');
2
3// First you need to create a connection to the database
4// Be sure to replace 'user' and 'password' with the correct values
5const con = mysql.createConnection({
6 host: 'localhost',
7 user: 'user',
8 password: 'password',
9});
10
11con.connect((err) => {
12 if(err){
13 console.log('Error connecting to Db');
14 return;
15 }
16 console.log('Connection established');
17});
18
19con.end((err) => {
20 // The connection is terminated gracefully
21 // Ensures all remaining queries are executed
22 // Then sends a quit packet to the MySQL server.
23});