wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Database access problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database access problems" Watch "Database access problems" New topic
Author

Database access problems

tom davies
Ranch Hand

Joined: Apr 27, 2012
Posts: 168
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.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19728
    
  10

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

Joined: Apr 27, 2012
Posts: 168
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
Sheriff

Joined: Oct 14, 2005
Posts: 19728
    
  10

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

Joined: Apr 27, 2012
Posts: 168
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.
 
Have you checked out Aspose?
 
subject: Database access problems
 
jQuery in Action, 3rd edition