Java를 사용하여 MS Access에서 만든 데이터베이스에 연결하려고하는데 관리 할 수 없습니다. ODBC를 사용하고 있는데이 예외가 발생합니다.
java.sql.SQLException : [Microsoft] [ODBC Driver Manager] 지정된 DSN에 드라이버와 응용 프로그램 간의 아키텍처 불일치가 있습니다.
내 자바 :
package javaapplication2;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @author Owner
*/
public class JavaApplication2 {
/**
* @param args the command line arguments
*
*/
public static void main(String[] args) {
// TODO code application logic here
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sourceURL = new String("jdbc:odbc:myDatabase");
System.out.println(sourceURL);
Connection dbConnection = DriverManager.getConnection(sourceURL,"admin","");
Statement myStmt = dbConnection.createStatement();
String query = "INSERT INTO People(ID, Name, Surname, Age, Contact, Location, Course) VALUES"
+ " (1007, 'Elroy', 'Smith', '33', 21366688, 'Somewhere', 'somecourse')";
myStmt.executeUpdate(query);
ResultSet results = myStmt.executeQuery("SELECT * FROM People");
while(results.next())
{
System.out.print(results.getString(1));
System.out.print(results.getString(2));
System.out.print(results.getString(3));
System.out.println(results.getString(4));
}
results.close();
}
catch(ClassNotFoundException cnfe)
{
System.out.println(cnfe);
}
catch(SQLException sqle)
{
System.out.println(sqle);
}
}
}