Yks' pyöräilijä

Eli opetus≫

Tietokanta Javaan

| 0 comments

Ubuntulla. Asenna Java, asenna JDBC-ajurit

sudo apt-get install libmysql-java

Tsekkaa polku; yhdelle käyttäjälle suoraan

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

Lyhyt koodi tsekkaamiseen:

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();
        }
    }
}

Kopsattu
https://marksman.wordpress.com/2009/03/01/setting-up-mysqljdbc-driver-on-ubuntu/

Leave a Reply

Required fields are marked *.