☕ java jdbc with mysql in ubuntu example

Опубликовано: 17 Март 2017
на канале: Open Source Devops
14,132
42

1. Assuming that you already have MySQL installed.
2.install the connector driver.
sudo apt-get install libmysql-java

3. The next step is to make sure that the classpath is set. You can have this set automatically by adding this
a command to you bashrc file.

export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar

4. If you want to set this for all users, you should modify the /etc/environment instead.



import java.sql.Connection;
import java.sql.DriverManager;
class JDBCTest {
private static final String url = "jdbc:mysql://localhost";
private static final String user = "username";
private static final String password = "password";
public static void main(String args[]) {
try {
Connection con = DriverManager.getConnection(url, user, password);
System.out.println("Success");
} catch (Exception e) {
e.printStackTrace();
}
}
} buy a coffee for me on this URL https://opensourcedevops.web.app or PayPal donation https://www.paypal.com/paypalme/OpenS...


Смотрите видео ☕ java jdbc with mysql in ubuntu example онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Open Source Devops 17 Март 2017, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 14,13 раз и оно понравилось 4 людям.