aspose file tools*
The moose likes JDBC and the fly likes Kindly help with the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Kindly help with the "cannot connect to the database" error" Watch "Kindly help with the "cannot connect to the database" error" New topic
Author

Kindly help with the "cannot connect to the database" error

nash avin
Ranch Hand

Joined: Nov 18, 2004
Posts: 45
Hello All,

I posted this message some time back, but dont know why nobody is answering it.It would be nice if somebody takes the time to help me out with this.I did look into the forums , but could not get a suitable error correction.

It would be great if someone helps me out in this very helpful forum.I am giving you the code I have so far written

/*** DatabaseConnection.java****/


/*** DatabaseConnection.java****/


Any help would be greatly appreciated.

Thanking you all in advance
AS
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What is the exact error message which is logged with the SQLException?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
nash avin
Ranch Hand

Joined: Nov 18, 2004
Posts: 45
Hi,

Thanks for the reply.Sorry to have not included the error message .The error message I get is as follows



Thank you again for your time.

Help would be greatly appreciated.

AS
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
One suggestion, could it be that you don't have access to add records to this particular database?
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
Originally posted by nash avin:





Don't you need to provide an username and a password to connect to the database?
Also, can you print out the sql statement, copy it and try to run it in some other utility to see if there is problem with the sql statement itself?

Jayesh
nash avin
Ranch Hand

Joined: Nov 18, 2004
Posts: 45
Hi ,

Thanks a lot for the replies.I did print it out in a SQL utility and the statement is al right.

Regarding whether I can do the inserts, I can , I did a select * from <tablename> and it workds fine.

But Why is it with the insert....

It would be great if any one can direct me in the right direction.

Thanking you
AS
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
I would suggest trying to run the exact same insert statement in the SQL utility using the same username/password
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by nash avin:
I posted this message some time back


3 hours??? Isn't that a touch impatient?
Personaly I was asleep. I try to set aside some time for this every day.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I can , I did a select * from <tablename> and it workds fine

Look at the permissions for the user you are connecting as - probably GUEST since you don't specify a username with your connection URL. Sounds like they only have permission to SELECT.

Also you might want to revise how you report the exception in your code - you have an error message "Unable to connect to DB" which will be logged when that is not the problem - you may well be able to connect, but you can't run the SQL. Generally trying to second guess what an exception will mean is not as good a strategy as just logging the stack trace and letting it tell you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Kindly help with the "cannot connect to the database" error
 
Similar Threads
Help with "unable to connect to database" problem
a mistake for bean
Formating Date objects
not able to establish connection for jdbcodbcdriver
Insert date and time into Oracle database