mercredi 14 juin 2017

Why does getting JDBC Connection need Reflection? [duplicate]

The code as following:

try{
    Class.forName("com.mysql.jdbc.Driver");
    Connection c=DriverManager.getConnection(url);
}catch(Exception e){
    System.err.println("no class!");
}

why geting Connection by JDBC need Class.forName(): the Reflection mechanism?Can import com.mysql.jdbc.Driver replace it?





Aucun commentaire:

Enregistrer un commentaire