Answers for "how to use jdbc mysql"

SQL
13

java connect to mysql

import java.sql.*;  
class MySqlConn{  
    public static void main(String args[]){  
        try{  
            Class.forName("com.mysql.cj.jdbc.Driver");  
            Connection conn = DriverManager.getConnection("jdbc:mysql://
            localhost:3306/databasename","username","password");  
            Statement stmt = conn.createStatement();  
            ResultSet rs = stmt.executeQuery("select * from emp");    
            con.close();  
        }catch(Exception ex){
            System.out.println(ex);
        }  
    }
}
Posted by: Guest on May-22-2020
3

mysql jdbc query

Connection conn = DriverManager.getConnection(url,username,password);
Statement stmt  = conn.createStatement();
String sql = "SELECT first_name, last_name, email " +
             "FROM candidates";
ResultSet rs    = stmt.executeQuery(sql)
Posted by: Guest on May-21-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language