1import java.sql.*;
2class MySqlConn{
3 public static void main(String args[]){
4 try{
5 Class.forName("com.mysql.cj.jdbc.Driver");
6 Connection conn = DriverManager.getConnection("jdbc:mysql://
7 localhost:3306/databasename","username","password");
8 Statement stmt = conn.createStatement();
9 ResultSet rs = stmt.executeQuery("select * from emp");
10 con.close();
11 }catch(Exception ex){
12 System.out.println(ex);
13 }
14 }
15}