MYSQL No suitable driver found
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
add a comment |
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
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18
add a comment |
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
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
mysql mariadb
edited Nov 12 at 9:52
asked Nov 10 at 13:12
Rafael Valls
1014
1014
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18
add a comment |
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18
add a comment |
2 Answers
2
active
oldest
votes
Class.forName should be called before getting connection
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
add a comment |
"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
}
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Class.forName should be called before getting connection
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
add a comment |
Class.forName should be called before getting connection
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
add a comment |
Class.forName should be called before getting connection
Class.forName should be called before getting connection
answered Nov 10 at 14:05
vinay chhabra
53937
53937
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
add a comment |
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
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
Nov 10 at 14:11
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
Nov 10 at 14:11
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
Because to get the connection you need to load the driver first.
– Killer
Nov 10 at 14:14
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
but if I use the mariadb driver, it works for me by loading it later: /
– Rafael Valls
Nov 10 at 14:20
add a comment |
"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
}
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
add a comment |
"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
}
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
add a comment |
"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
}
"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
}
answered Nov 10 at 14:13
Killer
4691519
4691519
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
add a comment |
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Oh nice its work, you know why with mariadb driver I can called Class.forName after?
– Rafael Valls
Nov 10 at 14:24
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
Don't know this, thanks for the info, will check..
– Killer
Nov 10 at 14:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
My guess is that the MySQL/MariaDB driver JAR is not on your classpath, and is therefore not available at runtime.
– Tim Biegeleisen
Nov 10 at 13:18