MYSQL No suitable driver found











up vote
0
down vote

favorite












I currently use Intellij, it turns out that I am trying to connect to a MySQL database, but after adding the library and using a connection class which works perfectly with the MariaDB driver, I find the error in the question title



public void conectar() {
try {
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
Class.forName("com.mysql.jdbc.Driver");
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Conexión fallida a : n " + url, "", JOptionPane.ERROR_MESSAGE);
System.out.println(ex.getMessage());
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "Error al cargar el driver", "", JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
}


enter image description here



enter image description here



These are the values ​​that I send to my class connection



c= new conexion("jdbc:mysql://", "127.0.0.1/", "root", "", "sanciones");
c.conectar();



And then I detail the connection class constructor



 public conexion(String driver,String host, String usuario, String 
contraseña, String baseDatos) {
this.usuario = usuario;
this.contraseña = contraseña;
this.baseDatos = baseDatos;
this.driver = driver;
this.host = host;
this.url = driver + this.host + this.baseDatos;
}


UPGRADE



The driver versions com.mysql.jdbc_5.1.5 do not allow the implicit loading of the driver due to the lack of the Services subfolder in META-INF and its corresponding content, even if it is JDBC4 and in the mysql manuals it is said that it is possible, it is not, at least with this specific version, greetings










share|improve this question









New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
    – Tim Biegeleisen
    2 days ago















up vote
0
down vote

favorite












I currently use Intellij, it turns out that I am trying to connect to a MySQL database, but after adding the library and using a connection class which works perfectly with the MariaDB driver, I find the error in the question title



public void conectar() {
try {
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
Class.forName("com.mysql.jdbc.Driver");
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Conexión fallida a : n " + url, "", JOptionPane.ERROR_MESSAGE);
System.out.println(ex.getMessage());
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "Error al cargar el driver", "", JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
}


enter image description here



enter image description here



These are the values ​​that I send to my class connection



c= new conexion("jdbc:mysql://", "127.0.0.1/", "root", "", "sanciones");
c.conectar();



And then I detail the connection class constructor



 public conexion(String driver,String host, String usuario, String 
contraseña, String baseDatos) {
this.usuario = usuario;
this.contraseña = contraseña;
this.baseDatos = baseDatos;
this.driver = driver;
this.host = host;
this.url = driver + this.host + this.baseDatos;
}


UPGRADE



The driver versions com.mysql.jdbc_5.1.5 do not allow the implicit loading of the driver due to the lack of the Services subfolder in META-INF and its corresponding content, even if it is JDBC4 and in the mysql manuals it is said that it is possible, it is not, at least with this specific version, greetings










share|improve this question









New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
    – Tim Biegeleisen
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I currently use Intellij, it turns out that I am trying to connect to a MySQL database, but after adding the library and using a connection class which works perfectly with the MariaDB driver, I find the error in the question title



public void conectar() {
try {
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
Class.forName("com.mysql.jdbc.Driver");
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Conexión fallida a : n " + url, "", JOptionPane.ERROR_MESSAGE);
System.out.println(ex.getMessage());
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "Error al cargar el driver", "", JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
}


enter image description here



enter image description here



These are the values ​​that I send to my class connection



c= new conexion("jdbc:mysql://", "127.0.0.1/", "root", "", "sanciones");
c.conectar();



And then I detail the connection class constructor



 public conexion(String driver,String host, String usuario, String 
contraseña, String baseDatos) {
this.usuario = usuario;
this.contraseña = contraseña;
this.baseDatos = baseDatos;
this.driver = driver;
this.host = host;
this.url = driver + this.host + this.baseDatos;
}


UPGRADE



The driver versions com.mysql.jdbc_5.1.5 do not allow the implicit loading of the driver due to the lack of the Services subfolder in META-INF and its corresponding content, even if it is JDBC4 and in the mysql manuals it is said that it is possible, it is not, at least with this specific version, greetings










share|improve this question









New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I currently use Intellij, it turns out that I am trying to connect to a MySQL database, but after adding the library and using a connection class which works perfectly with the MariaDB driver, I find the error in the question title



public void conectar() {
try {
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
Class.forName("com.mysql.jdbc.Driver");
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Conexión fallida a : n " + url, "", JOptionPane.ERROR_MESSAGE);
System.out.println(ex.getMessage());
} catch (ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, "Error al cargar el driver", "", JOptionPane.ERROR_MESSAGE);
System.out.println(e.getMessage());
}
}


enter image description here



enter image description here



These are the values ​​that I send to my class connection



c= new conexion("jdbc:mysql://", "127.0.0.1/", "root", "", "sanciones");
c.conectar();



And then I detail the connection class constructor



 public conexion(String driver,String host, String usuario, String 
contraseña, String baseDatos) {
this.usuario = usuario;
this.contraseña = contraseña;
this.baseDatos = baseDatos;
this.driver = driver;
this.host = host;
this.url = driver + this.host + this.baseDatos;
}


UPGRADE



The driver versions com.mysql.jdbc_5.1.5 do not allow the implicit loading of the driver due to the lack of the Services subfolder in META-INF and its corresponding content, even if it is JDBC4 and in the mysql manuals it is said that it is possible, it is not, at least with this specific version, greetings







mysql mariadb






share|improve this question









New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 21 hours ago





















New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Rafael Valls

1062




1062




New contributor




Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Rafael Valls is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
    – Tim Biegeleisen
    2 days ago


















  • My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
    – Tim Biegeleisen
    2 days ago
















My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
2 days ago




My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
2 days ago












2 Answers
2






active

oldest

votes

















up vote
0
down vote













Class.forName should be called before getting connection






share|improve this answer





















  • This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
    – Rafael Valls
    2 days ago










  • Because to get the connection you need to load the driver first.
    – Killer
    2 days ago










  • but if I use the mariadb driver, it works for me by loading it later: /
    – Rafael Valls
    2 days ago


















up vote
0
down vote













"Class.forName" need to be called first to load the proper driver first.Try this,



    try {
Class.forName("com.mysql.jdbc.Driver");
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}





share|improve this answer





















  • Oh nice its work, you know why with mariadb driver I can called Class.forName after?
    – Rafael Valls
    2 days ago










  • Don't know this, thanks for the info, will check..
    – Killer
    2 days ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Rafael Valls is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239288%2fmysql-no-suitable-driver-found%23new-answer', 'question_page');
}
);

Post as a guest
































2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













Class.forName should be called before getting connection






share|improve this answer





















  • This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
    – Rafael Valls
    2 days ago










  • Because to get the connection you need to load the driver first.
    – Killer
    2 days ago










  • but if I use the mariadb driver, it works for me by loading it later: /
    – Rafael Valls
    2 days ago















up vote
0
down vote













Class.forName should be called before getting connection






share|improve this answer





















  • This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
    – Rafael Valls
    2 days ago










  • Because to get the connection you need to load the driver first.
    – Killer
    2 days ago










  • but if I use the mariadb driver, it works for me by loading it later: /
    – Rafael Valls
    2 days ago













up vote
0
down vote










up vote
0
down vote









Class.forName should be called before getting connection






share|improve this answer












Class.forName should be called before getting connection







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









vinay chhabra

52937




52937












  • This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
    – Rafael Valls
    2 days ago










  • Because to get the connection you need to load the driver first.
    – Killer
    2 days ago










  • but if I use the mariadb driver, it works for me by loading it later: /
    – Rafael Valls
    2 days ago


















  • This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
    – Rafael Valls
    2 days ago










  • Because to get the connection you need to load the driver first.
    – Killer
    2 days ago










  • but if I use the mariadb driver, it works for me by loading it later: /
    – Rafael Valls
    2 days ago
















This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
– Rafael Valls
2 days ago




This works!!! but I have a great doubt, I read that class for name is not necessary for the operation of the library, why would it be necessary to place it in this case?
– Rafael Valls
2 days ago












Because to get the connection you need to load the driver first.
– Killer
2 days ago




Because to get the connection you need to load the driver first.
– Killer
2 days ago












but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
2 days ago




but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
2 days ago












up vote
0
down vote













"Class.forName" need to be called first to load the proper driver first.Try this,



    try {
Class.forName("com.mysql.jdbc.Driver");
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}





share|improve this answer





















  • Oh nice its work, you know why with mariadb driver I can called Class.forName after?
    – Rafael Valls
    2 days ago










  • Don't know this, thanks for the info, will check..
    – Killer
    2 days ago















up vote
0
down vote













"Class.forName" need to be called first to load the proper driver first.Try this,



    try {
Class.forName("com.mysql.jdbc.Driver");
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}





share|improve this answer





















  • Oh nice its work, you know why with mariadb driver I can called Class.forName after?
    – Rafael Valls
    2 days ago










  • Don't know this, thanks for the info, will check..
    – Killer
    2 days ago













up vote
0
down vote










up vote
0
down vote









"Class.forName" need to be called first to load the proper driver first.Try this,



    try {
Class.forName("com.mysql.jdbc.Driver");
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}





share|improve this answer












"Class.forName" need to be called first to load the proper driver first.Try this,



    try {
Class.forName("com.mysql.jdbc.Driver");
conexion = DriverManager.getConnection(url, usuario, contraseña);
if (conexion != null) { JOptionPane.showMessageDialog(null, "Conexión establecida a : n" + url, "ACDA2", JOptionPane.INFORMATION_MESSAGE);
stm = conexion.createStatement();//crea un objeto que permite enviar instrucciones a la base de datos
}






share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Killer

4691519




4691519












  • Oh nice its work, you know why with mariadb driver I can called Class.forName after?
    – Rafael Valls
    2 days ago










  • Don't know this, thanks for the info, will check..
    – Killer
    2 days ago


















  • Oh nice its work, you know why with mariadb driver I can called Class.forName after?
    – Rafael Valls
    2 days ago










  • Don't know this, thanks for the info, will check..
    – Killer
    2 days ago
















Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
2 days ago




Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
2 days ago












Don't know this, thanks for the info, will check..
– Killer
2 days ago




Don't know this, thanks for the info, will check..
– Killer
2 days ago










Rafael Valls is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Rafael Valls is a new contributor. Be nice, and check out our Code of Conduct.













Rafael Valls is a new contributor. Be nice, and check out our Code of Conduct.












Rafael Valls is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239288%2fmysql-no-suitable-driver-found%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python