I have a Java program that connects to an external Microsoft Access database. The following shows code in a databasehandler class, that is used to connect to the database.
static public int makeConnectionToFIREPLACEDB() {
try {
// Make connection to Database
connectionToFIREPLACEDB = DriverManager.getConnection("jdbc:odbc:FIREPLACE");
} catch (SQLException exception) {
return (-1); // Return back with -1 if there is a problem
// making a connection
}
return (0); // Return back with 0 if connection is made to database
} // end
The follow shows part of the code for a class of the program that uses the external database. This class views data from the database (which is at the bottom of the code but isn't necessary for this question). When I try to access the database I get the following error: Unable to connect to the database table FIREPLACE.
if ( DataBaseHandler.loadDriver() == -1 ) {
JOptionPane.showMessageDialog (frame, "Problem loading the JDBC/ODBC driver.");
// Check to see if we can connect to the database table
} else if ( DataBaseHandler.makeConnectionToFIREPLACEDB() == -1 ) {
JOptionPane.showMessageDialog (frame, "Unable to connect to the database table FIREPLACE");
} else { // Search for all the fireplaces
// ...show data
So I cannot connected too external database, any help would be much appreciated.
Update: get the following error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application