I am learning how to manage information I saved a long time ago in Access 2003 databases (and how to rewrite in Java user interfaces I prepared and programs I wrote at that time). I was satisfied of my results when, unfortunately, I updated my jdk from 7 to 8 edition. And I was no more able to connect my databases.
I looked for pure Java JDBC Driver and found UCanAccess.
I downloaded it and unzipped it in a directory named Programmi\UcanAccess-3.0.1-bin.
I added the directory to system variable PATH as C:\Program Files\UCanAccess-3.0.1-bin.
I tried to open database by means of these instructions (that, as far as I remember, I found at UCanAccess Web Site):
String driver = "net.ucanaccess.jdbc.UcanaccessDriver";
Class.forName(driver);
but I got the ClassNotFoundException.
1st quetion) I suppose I have to add something after having imported java.sql.; but what I have to import?
2nd question) Have I to add some other directory to PATH?
I know these are questions of a beginner and, in such a matter, I am a beginner. I would appreciiate if anyone can help me a little bit.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have already had a look at that site. Expecially at "Option 2: Manually adding the JARs to your project". But there is no answer to my question. At least no answer I can understand.
Anyway thaks for your propmt reply.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Iread at the site the following (and I put in capital letters my questions):
"Option 2: Manually adding the JARs to your project
As mentioned above, UCanAccess requires Jackcess and HSQLDB. Jackcess in turn has its own dependencies. So to use UCanAccess you will need to include (WHERE?) the following components:
UCanAccess (ucanaccess-2.x.x.jar)
HSQLDB (hsqldb.jar, version 2.2.5 or newer)
Jackcess (jackcess-2.x.x.jar)
commons-lang (commons-lang-2.4.jar, or newer)
commons-logging (commons-logging-1.0.4.jar, or newer)
Fortunately, UCanAccess includes all of the required JAR files in its distribution file. When you unzip it you will see something like
All you need to do is add all five (5) JARs to your project. (I DO NOT KNOW WHAT EXACTLY MEANS "TO ADD THE FILES TO MY PROJECT. I have just the attached class ArticoliVers0Java8.java):
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
importjava.sql.*;//Withnextlinethecompilergivesanerror:"package net.ucanaccess.jdbc does not existimportnet.ucanaccess.jdbc.*;publicclassArticoliVers0Java8{publicstaticvoidmain(Stringargs[]){Connectioncon=null;Statementst=null;ResultSetrs=null;try{//Carichiamoundriverditipo1(bridgejdbc-odbc)Stringdriver="net.ucanaccess.jdbc.UcanaccessDriver";Class.forName(driver);//ClassNotFoundException//CreiamolastringadiconnessionealdatabaseArticoliStringurl="jdbc:ucanaccess://C:/Users/FrancoW/Java/ApplicazioniMie/Articoli/ProveParziali/Articoli.mdb";con=DriverManager.getConnection(url,"","");//CreiamounoggettoStatementperinterrogareildbst=con.createStatement();//Eseguiamounaqueryeimmagazziniamoneirisultati//inunoggettoResultSetStringqry="SELECT * FROM tblArchivi";rs=st.executeQuery(qry);//Stampiamoneirisultatirigaperrigawhile(rs.next()){System.out.println(rs.getString("N")+" "+rs.getString("Descrizione")+" ID = "+rs.getString("IDArchivio"));}}catch(SQLExceptione){e.printStackTrace();}catch(ClassNotFoundExceptione){e.printStackTrace();}finally{if(rs!=null){try{rs.close();}catch(SQLExceptione){e.printStackTrace();}}rs=null;if(st!=null){try{st.close();}catch(SQLExceptione){e.printStackTrace();}}st=null;if(con!=null){try{con.close();}catch(SQLExceptione){e.printStackTrace();}}con=null;}}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your issue doesn't seem to be ucanaccess related, but you should to understand how to add jars to a project classpath using your IDE or your startup script(.bat or .sh). We can obviously explain and teach this, but it's out of this forum's scope. Are you using an IDE or not? What's your IDE? Eclipse? NetBeans? Gord's article shows clearly how to do with both.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am learning how to manage information I saved a long time ago in Access 2003 databases (and how to rewrite in Java user interfaces I prepared and programs I wrote at that time). I was satisfied of my results when, unfortunately, I updated my jdk from 7 to 8 edition. And I was no more able to connect my databases.
I looked for pure Java JDBC Driver and found UCanAccess.
I downloaded it and unzipped it in a directory named Programmi\UcanAccess-3.0.1-bin.
I added the directory to system variable PATH as C:\Program Files\UCanAccess-3.0.1-bin.
I tried to open database by means of these instructions (that, as far as I remember, I found at UCanAccess Web Site):
String driver = "net.ucanaccess.jdbc.UcanaccessDriver";
Class.forName(driver);
but I got the ClassNotFoundException.
1st quetion) I suppose I have to add something after having imported java.sql.; but what I have to import?
2nd question) Have I to add some other directory to PATH?
I know these are questions of a beginner and, in such a matter, I am a beginner. I would appreciiate if anyone can help me a little bit.
Have a look at
http://stackoverflow.com/q/21955256/2144390
I have already had a look at that site. Expecially at "Option 2: Manually adding the JARs to your project". But there is no answer to my question. At least no answer I can understand.
Anyway thaks for your propmt reply.
Iread at the site the following (and I put in capital letters my questions):
"Option 2: Manually adding the JARs to your project
As mentioned above, UCanAccess requires Jackcess and HSQLDB. Jackcess in turn has its own dependencies. So to use UCanAccess you will need to include (WHERE?) the following components:
UCanAccess (ucanaccess-2.x.x.jar)
HSQLDB (hsqldb.jar, version 2.2.5 or newer)
Jackcess (jackcess-2.x.x.jar)
commons-lang (commons-lang-2.4.jar, or newer)
commons-logging (commons-logging-1.0.4.jar, or newer)
Fortunately, UCanAccess includes all of the required JAR files in its distribution file. When you unzip it you will see something like
ucanaccess-2.0.4.jar
lib/commons-lang-2.6.jar
lib/commons-logging-1.1.3.jar
lib/hsqldb.jar
lib/jackcess-2.0.3.jar
All you need to do is add all five (5) JARs to your project. (I DO NOT KNOW WHAT EXACTLY MEANS "TO ADD THE FILES TO MY PROJECT. I have just the attached class ArticoliVers0Java8.java):
Sorry. Here the class ArticoliVers0Java8.java
Your issue doesn't seem to be ucanaccess related, but you should to understand how to add jars to a project classpath using your IDE or your startup script(.bat or .sh). We can obviously explain and teach this, but it's out of this forum's scope. Are you using an IDE or not? What's your IDE? Eclipse? NetBeans? Gord's article shows clearly how to do with both.
OK, Marco and Gord.
I found what I needed at http://sourceforge.net/p/ucanaccess/discussion/help/thread/b9165c19/
Thank you.