• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Database access problems

 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this problem has confused me, i will outline what the program does first before i tell you the issue i am having.
I have set up HSQLDB i have created a program which reads from my database.properties file and connects to the database.
I then use this connection to perform some SQL commands such as add, remove and update entries from a simple console menu. If i enter my connection details manually so the url, username, password and driver it connects fine. When doing it manually i have username and password both as "", so the value is null. It all works fine then, my menu works, i can add, delete, update and display my table. If however, i try and connect by directing my program to the details in my database.properties file which also has a blank username and password field i cannot connect, i get this error message.

Exception in thread "main" java.sql.SQLInvalidAuthorizationSpecException: invalid authorization specification - not found: SA

I wanted to see what values were being used to connect so i put a println in to display the username and password when entering my details manually and also from reading from the file.
So when i attempt to establish a connection it shows me this line first. They both display username=null and password= null but if i link to the database.properties file i get the error message mentioned above . . . .It doesn't make sense to me as if a password/username were required, why can i connect by manually setting these to "" in my connection program?

Below is the connection program, you can see in the getConnection method i have the username and password field set to "". To use the values read from the file i use username and password instead.
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But isn't that just a repost of this thread: http://www.coderanch.com/t/594246/JDBC/databases/Connecting-database?

It looks to me as if you have ignored almost everything which was said in that thread.
 
tom davies
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:But isn't that just a repost of this thread: http://www.coderanch.com/t/594246/JDBC/databases/Connecting-database?

It looks to me as if you have ignored almost everything which was said in that thread.


Not really because i can read the file now, that is no longer the problem. The issue is that i can connect to the database by manually entering the details, but if i use the same (blank) details i read from the file it wont let me access the database and gives me the above error message. I have checked that i can read the details correctly from the properties file, the problem is explained in more detail in my first post.
 
Paul Clapham
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I already said in that other thread, you aren't calling the init() method anywhere. You still aren't calling it anywhere.
 
tom davies
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:As I already said in that other thread, you aren't calling the init() method anywhere. You still aren't calling it anywhere.


Turns out i followed your advice for my test program but did not implement it into my actual program!
Apologise, and thanks for the slap round the head.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!