Ad Code

Responsive Advertisement

Quick Suggests :-

6/recent/ticker-posts

Java | MySQL Database Connection

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DatabaseConnection {
    
    public static Connection c;
   
    static{
       
        try {
           
           Class.forName("com.mysql.cj.jdbc.Driver");
           String url = "jdbc:mysql://localhost:****/********";
           String un ="****";
           String pw = "********";
           c = DriverManager.getConnection("jdbc:mysql://localhost:****/********?useSSL=false","****","********");
           
        } catch (Exception e) {
            e.printStackTrace();
        }
     
    }
 
    public static void iud(String q) throws Exception{
  
        Statement s = c.createStatement();
        s.executeUpdate(q);
   
    }
   
    public static ResultSet search(String q) throws Exception{
   
       Statement s= c.createStatement();
       ResultSet rs=s.executeQuery(q);
       return rs; 
   
    }
    
}

E-Mail :- gawesh2020java@gmail.com
Youtube :- https://www.youtube.com/channel/UCwm7djDtBaueTDqXt_GIFKw
Linkedin :- https://lk.linkedin.com/in/gawesh-prabhashwara-792ab1205
Facebook :- https://www.facebook.com/gawesh98
Twitter :- https://twitter.com/gawesh_98
Instagram :- https://www.instagram.com/gawezh/
Tiktok :- https://www.tiktok.com/@gawesh_prabhashwara?lang=en

Post a Comment

0 Comments