Question

I'm having a Java class and I'm really new to Database Connectivity.. My professor and everyone else on this class use Windows and an Access Database, and I'm the only one using GNU/Linux with a MYSQL Database.
Now as you know Windows programmers use ODBC, but as I searched, I got that it's only for windows. I found a Unix/Linux ODBC from easysoft but it doesn't support MYSQL
Is there any Open-Source ODBC you know of that supports MYSQL?
Moreover how should I use this Driver in java?
Couldn't find neither a documentation nor a tutorial for GNU/Linux..

Was it helpful?

Solution

Just install MySQL Connectors from this link

Code to connect to mysql via jdbc :

import java.lang.*;
import java.sql.*;

public class Demo {
    public static void main(String[] args){
        try{
            Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?" + "user=test&password=123456");
        }catch(SQLException ex){
            System.out.println("SQLException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
        }catch(Exception ex){
            System.out.println("Exception: " + ex.getMessage());
        }
    }                                             
}

OTHER TIPS

MySQL provides both ODBC and JDBC drivers. Check their web site. Documentation is also provided.

Don't worry about ODBC drivers. You just need the MySQL JDBC driver.

https://dev.mysql.com/downloads/connector/j/

Here is also some info on setting up the connection:

What is the MySQL JDBC driver connection string?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top