Java8에서는 java경로 /jre/bin/에 JdbcOdbc.dll 파일을 가지고 있지 않아서

java7에서 java8의 경로에 복사해야 사용가능함 

 

 

연결 셈플 소스 

import java.sql.*;
 
public class JDBCAccess {
 
    public static void main(String[] args) {
        JDBCAccess jdbcAccess = new JDBCAccess();
        jdbcAccess.run();
    }
 
    public void run() {
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            java.util.Properties props = new java.util.Properties();
    		props.put("charSet", "euc-kr");
            // javasubname ist der bei der Datenquelle festgelgte subname
            Connection connection = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=D:/test.xls",props);
            Statement statement = connection.createStatement();
            ResultSet result = statement.executeQuery
            ("SELECT * FROM [test$]");
            //System.out.println("ID, Name: ");
            while (result.next()) {
            	System.out.println(result.getString(1));
            }
            result.close();
            statement.close();
            connection.close();
        }
        catch(java.lang.ClassNotFoundException e) {
            System.out.println("JDBC-ODBC-Driver not found");
        }
        catch(java.sql.SQLException e) {
            System.out.println("Error on database"
                    + e.getMessage());
        }
    }
}

+ Recent posts