NCEAS / morpho

Morpho metadata editor
GNU General Public License v2.0
3 stars 1 forks source link

Import of MS Access database fails #1072

Closed csjx closed 5 months ago

csjx commented 6 years ago

When trying to import data tables from a Microsoft Access database, the operation silently fails on Windows 10 with Java 8. The log file shows an error:

Problem getting data from clipboard

This comes from DataPackagePlugin.hasClipboardData() where the call:

Transferable t = c.getToolkit().getSystemClipboard().getContents(null);

succeeds but the subsequent call to:

sel = (String)t.getTransferData(DataFlavor.stringFlavor);

fails.

Figure out if this is a platform specific issue, or perhaps a Java version issue due to API changes when interacting with the clipboard, or some other reason entirely.

taojing2002 commented 6 years ago

After debugging, I got different error message:

java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
 at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:264)
 at edu.tesc.scidb.MetadataChecker.CreateTdmRep.getRep(CreateTdmRep.java:44)
 at edu.tesc.scidb.morpho.plugins.ImportMSAccessPlugin.pickDatabase(ImportMSAccessPlugin.java:99)
 at edu.tesc.scidb.morpho.plugins.ImportMSAccessPlugin.execute(ImportMSAccessPlugin.java:71)

It looks like that the jdbc connection can't be got.

csjx commented 6 years ago

This might be an easy fix. The Sun JDBC driver has been deprecated in Java 8 by Oracle:

JDBC-ODBC bridge driver has been marked as "don't use" for the last decade or so. It was present in Java 7 release but removed from Java 8 release onward

Consider using type 4 JDBC, pure Java driver with real database or if you still want to connect to MS access, use Jackcess library ...

From https://javarevisited.blogspot.com/2015/07/how-to-solve-javalangclassnotfoundexception-sun.jdbc.odbc.jdbcodbcdriver.html

taojing2002 commented 6 years ago

I tried to import a ms access database into a released morpho under java 1.7. It still doesn't work. From the above notes, it should work. So it maybe has another issues.

csjx commented 6 years ago

Hmm - well, the Type 4 JDBC libraries mentioned above don't work with MS Access, and the Jackcess library isn't JDBC, so the plugin would need to be rewritten when connecting to the database. So, it seems that this is not so easy of a fix. I wonder what the issue is under Java 7 @taojing2002 ? We're kind of dead-ended at Java 8 without putting some development time in. We might want to disable that Import ... menu item in Morpho if it's no longer supported. @mbjones thoughts?

taojing2002 commented 6 years ago

The error message is: Database - [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified I searched and found the issue associated with the 64-bit os: https://stackoverflow.com/questions/20208151/database-microsoftodbc-driver-manager-data-source-name-not-found-and-no-de It seems we need to twist the machine and it is hard for regular users.