Hi everyone, so i have been teaching myself Java programming this month and i was following several tutorials on Using Access databases and pulling data and checking data from the database to a user entered field. anyways short of it i only realize after learning all about it that the Access driver are no longer supported!!
so i found out about ucanaccess!! HOORAY i think to myself!
but then i hit my next problem.
so i have both the zip files...
can download the readme sadly!
but i can seem to get net.ucanaccess.(ECTECT) to get recognized in netbeans.
i have fairly basic knowledge of netbeans and have attempted to install the drivers.
i firstly went to services Databases/Drivers and add new driver i pulled all the .Jar files from the zip file. (5 in total i think.) the only Driver Class it finds (in the dropdown Below is org.hsqldb.jdbcDriver) so i add and i have one new driver called HSQLDB in the drivers folder.
i then went to projects tab PROJECT NAME/Libraries right click add Jar/Folder i then added the 2 ZIP files here and i also added them in their unzipped forms.
but still when i try to import net.ucanaccess Netbeans tells me it can find it.
please please please could someone walk me through this as a newer user i find the only instructions i have found to be fairly technical or lacking in information.
once i know i will create a Youtube Tutorial for other newbies like myself.
Thanks in advance and sorry for rambling on i just wanted to make sure i gave the full picture!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I like rambling. But someone has already done these steps.
See Question&Answer(mainly the first answer in the list) at http://stackoverflow.com/questions/23193143/conflict-between-netbeans-ide-8-0-and-ucanaccess.
Notice that you never have to use the zip files, (it's a distribution)but add to your classpath all jars into the ucanaccess-bin.zip.
The Driver class name is net.ucanaccess.jdbc.UcanaccessDriver and if you do correctly the service installation, it will appear in the in the dropdown.
Also, in order to use the drive in a java project, you have to add all libraries to the classpath as well.
Please, if something doesn't work, let me know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok i finally got them into a library and setup.
im having a little trouble with it still im not returning any errors from my catches so it doesnt seem to be going wrong in the coding. but im basically changing my code from an old MS access JDBC driver to ucanaccess driver so i may have mad a mistake.
JOptionPane.showMessageDialog(null, "User Not Found!");
}
}
catch(Exception ex){
System.out.println("ERROR: " +ex);
}
basically checks to see if password is matched. if matched more than once it or not at all it returns different.
But when i run my program and test it for a positive value or a duplicated value in my database it does not Query properly for some reason and returns "User Not Found!" every time.
also i was not sure weather u had to or not but i added it in just incase.
do i need to import as below?
or am i missing something that needs importing?
sorry for 20 Questions just been stuck on this for the day and really want to move on from this tutorial :D
import net.ucanaccess.jdbc.UcanaccessConnection;
import net.ucanaccess.jdbc.UcanaccessDriver;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
you don't need the imports above.
Make sure to have correctly saved the data in the accdb.
Anyway, you can try your queries(if you want, after having logged them in your program:System.out.println(sql)) or try
select * from table2;
or try any sql statement you want
using the console.bat or console.sh in the distribution.
Cheers Marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone, so i have been teaching myself Java programming this month and i was following several tutorials on Using Access databases and pulling data and checking data from the database to a user entered field. anyways short of it i only realize after learning all about it that the Access driver are no longer supported!!
so i found out about ucanaccess!! HOORAY i think to myself!
but then i hit my next problem.
so i have both the zip files...
can download the readme sadly!
but i can seem to get net.ucanaccess.(ECTECT) to get recognized in netbeans.
i have fairly basic knowledge of netbeans and have attempted to install the drivers.
i firstly went to services Databases/Drivers and add new driver i pulled all the .Jar files from the zip file. (5 in total i think.) the only Driver Class it finds (in the dropdown Below is org.hsqldb.jdbcDriver) so i add and i have one new driver called HSQLDB in the drivers folder.
i then went to projects tab PROJECT NAME/Libraries right click add Jar/Folder i then added the 2 ZIP files here and i also added them in their unzipped forms.
but still when i try to import net.ucanaccess Netbeans tells me it can find it.
please please please could someone walk me through this as a newer user i find the only instructions i have found to be fairly technical or lacking in information.
once i know i will create a Youtube Tutorial for other newbies like myself.
Thanks in advance and sorry for rambling on i just wanted to make sure i gave the full picture!
I like rambling. But someone has already done these steps.
See Question&Answer(mainly the first answer in the list) at http://stackoverflow.com/questions/23193143/conflict-between-netbeans-ide-8-0-and-ucanaccess.
Notice that you never have to use the zip files, (it's a distribution)but add to your classpath all jars into the ucanaccess-bin.zip.
The Driver class name is net.ucanaccess.jdbc.UcanaccessDriver and if you do correctly the service installation, it will appear in the in the dropdown.
Also, in order to use the drive in a java project, you have to add all libraries to the classpath as well.
Please, if something doesn't work, let me know.
ok i finally got them into a library and setup.
im having a little trouble with it still im not returning any errors from my catches so it doesnt seem to be going wrong in the coding. but im basically changing my code from an old MS access JDBC driver to ucanaccess driver so i may have mad a mistake.
here is the code im using to connect :
try
{
String driver = "net.ucanaccess.jdbc.UcanaccessDriver";
Class.forName(driver);
String db = "jdbc:ucanaccess://C:/db1.accdb";
con = DriverManager.getConnection(db);
st = con.createStatement();
}
catch(ClassNotFoundException | SQLException ex){
System.out.println("ERROR" +ex);
}
as i say no errors back form this
i then have code for checking Username and password fields to the database as below.
public void actionPerformed(ActionEvent e) {
try{
String user = t.getText().trim();
String pass = t1.getText().trim();
String sql = "select user,pass from Table2 where user='"+user+"'and #pass='"+pass+"'";
rs = st.executeQuery(sql);
int count = 0;
while (rs.next()){
count = count + 1;
}
if(count == 1){
JOptionPane.showMessageDialog(null, "User found in database!!!");
}
else if(count > 1){
JOptionPane.showMessageDialog(null, "Dupe Found");
}
else{
JOptionPane.showMessageDialog(null, "User Not Found!");
}
}
catch(Exception ex){
System.out.println("ERROR: " +ex);
}
basically checks to see if password is matched. if matched more than once it or not at all it returns different.
But when i run my program and test it for a positive value or a duplicated value in my database it does not Query properly for some reason and returns "User Not Found!" every time.
also i was not sure weather u had to or not but i added it in just incase.
do i need to import as below?
or am i missing something that needs importing?
sorry for 20 Questions just been stuck on this for the day and really want to move on from this tutorial :D
import net.ucanaccess.jdbc.UcanaccessConnection;
import net.ucanaccess.jdbc.UcanaccessDriver;
Hi,
you don't need the imports above.
Make sure to have correctly saved the data in the accdb.
Anyway, you can try your queries(if you want, after having logged them in your program:System.out.println(sql)) or try
select * from table2;
or try any sql statement you want
using the console.bat or console.sh in the distribution.
Cheers Marco