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

Setting Up MySQL/JDBC Driver on Ubuntu

Leave a Reply

Required fields are marked *.


css.php