JDBC 커넥터는

https://downloads.mariadb.org/connector-java/

위 링크에서 다운로드 가능합니다.


다운로드 받은 커넥터는 라이브러리에 추가해준뒤 데이터베이스 커넥션 소스에서 드라이버를 임포트 해줍니다.

import org.mariadb.jdbc.Driver;


connectToDB 라는 예제 메소드를 작성해보았습니다.

    private static Connection connectToDB() {
        try {
            Class.forName("org.mariadb.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try {
                String jdbcUrl="jdbc:mariadb://localhost:3306/testdb?autoReconnect=true";
                String userId="root";
                String userPass="root";
                Connection con = DriverManager.getConnection(jdbcUrl,userId,userPass);
            if (!propsInited) {
                long timeout = getWaitTimeout(con);
                if (timeout == -1) {
                } else {
                    connectionTimeOut = timeout;
                }
                propsInited = true;
            }
            return con;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }


String 문자열을 선언해서 유저 아이디와 유저 패스워드를 더욱 간단히 설정할 수 있게 소스를 구성하였습니다.

jdbc연결 Url에서 jdbc:mysql 가 아닌 jdbc:mariadb로


역시 mysql의 업그레이드 버전이라 그런건지 소스 구성도 mysql JDBC연동 소스와 매우 흡사하다고 볼 수 있습니다.



이제부터 블로그 주소는 http://etssun.com 이며,


현재 DNS 만기일은 2019 06 15 지만 추가적인 연장을 하면서 이용할 예정입니다.



DNS 제공 업체는 

https://www.gabia.com/


가비아를 사용하였습니다.


'이런저런 이야기' 카테고리의 다른 글

JDBC - MariaDB 와 Java 연동 메소드 예제  (0) 2018.07.30

+ Recent posts