Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Problem with SQL in an Access database

 
Ranch Hand
Posts: 459
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my code

I have  been using the getConnection method for years; it gets a connection to a MS Access database using ucanaccess, but the problem is not with ucanaccess. The Exception error message is

I am getting the connection with this code

I am using userName Admin and password "" because in Access the default username is Admin and there is no password; but I could be wrong. I have exhausted the Internet and I have not found the solution.
 
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message says "user lacks privilege" as one possibility. And you're talking about passwords as if you're considering that possibility. So the key question now is, have you successfully connected to that particular Access database before?
 
Alejandro Barrero
Ranch Hand
Posts: 459
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Paul for your prompt reply; well the message doesn't include password so it appears the reason for the problem is different. I have connected to copies of that database many times in the last ten years with exactly that code for "getConnection()", but is an old program in Eclipse full of syntax errors today for some ungodly reason and I haven't been able to find out what values of userName and password I was using; on the other hand something may have changed in my computer or Microsoft may have changed Access. The messages indicates that I am using ucanaccess although the cause is a java.sql.SQLSyntaxErrorException, of course I have ran the SQL statement directly in Access and it works. At this time I am trying to create a user in Access with a userName and password  but I haven't found a way yet. Currently I am using the Maven dependency for ucanaccess but I will try the jar files from the old program
 
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how the UCanAccess driver is supposed to work, but could it be that if you're using file paths that the driver uses the user account that your application is running under? If that is the case, you should check the file access permissions on your database file.
 
Alejandro Barrero
Ranch Hand
Posts: 459
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Stephan; the only file I am using is the one specifying the location of the database.
I was using Maven to load the ucanaccess jars, and eliminated it to load difrectly  the jar files but to no avail I still have the same problem. In Access I created a use  with a login name and password and now to the the database I have to use login name and password; I also gave that user all the permissions in ACCESS. It appears I am going to have to do it the old fashioned way "No ucanaccess just a DNS".
 
Alejandro Barrero
Ranch Hand
Posts: 459
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally found a class in the internet working with ucanaccess that worked for me, but worked for a SELECT not for an UPDATE; I changed my code for a SELECT and it works fine. The question now is why can I not use UPDATE? It worked in previous years; the program from the Internet doesn't use user name or password and my program also runs without them.
 
Stephan van Hulst
Saloon Keeper
Posts: 11882
253
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is not authentication (user name, password) but authorization (permissions).

You must edit your database to give the user you're logging in as permission to modify your table contents.
 
I will suppress my every urge. But not this shameless plug:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic