Posts

Showing posts from December, 2020

SQL

Image
 

java database connectivity

 Steps: 7 Steps to Connect Application to database 1)Import the package 2)Load and Register driver 3)Create Connection 4)Create Statement 5)Execute the query 6)process the results 7)close connection package jdbc; import java.sql.*; import java.sql.Connection; import java.sql.DriverManager; //7 Steps to Connect Application to database // //1)Import the package // //2)Load and Register driver // //3)Create Connection // //4)Create Statement // //5)Execute the query // //6)process the results // //7)close connection PROGRAM: package jdbc; import java.sql.*; import java.sql.Connection; import java.sql.DriverManager; public class Democlass { // program to fetch data from mysql public static void main(String[] args) throws Exception { String url ="jdbc:mysql://localhost:3306/telusko"; //telusko: name of db String uname = "root"; String pass = "root"; String query = "select * from master"; Class.forName("com.mysql.cj.jdbc.Dri