MySQL Connection in Java

Add your thoughts here… (optional)

Devesh Sharma

Here is an example to show how to connect to MySQL database in Java.

First things first. If you are using Maven, please add the MySQL dependency in your pom.xml file. The dependency looks like this:

If you are NOT using Maven, you need to download the MySQL JDBC driver. The driver can be found here. The download contains a JAR file which you need to add to your classpath.

That is it! Here is the code to connect to MySQL database in Java:

Ver la entrada original

2 comentarios en “MySQL Connection in Java”

Deja una respuesta

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Salir /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Salir /  Cambiar )

Conectando a %s