This question already has an answer here:
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