• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the exact error message which is logged with the SQLException?
 
nash avin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One suggestion, could it be that you don't have access to add records to this particular database?
 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest trying to run the exact same insert statement in the SQL utility using the same username/password
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic