Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alert Message in B&S

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All,

After starting server , when user will run network client and if he specified wrong ip address or port of server then I am displaying message in AlertBox "Failed to connect to database ".

Should I specified more detail with the above message like "Failed to connect to database since ip address/port are wrong" ?

when user type wrong ip address or port on console I get

SEVERE: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect




how can I know user specified wrong ip address or port . It just throw above exception in both case (wrong ip address and wrong port )

or to display message in AlertBox "Failed to connect to database ". is sufficient
otherwise we should give more detail to user why connection failed because of ip address or port or both?


please reply.


thanks
pramod
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This looks like a design decision (albeit a small one) about the granularity of your error messages. Therefore it is your call whether you think you need to show this information or not.

Just make sure you document any design decisions in your choices.txt file for the assesor to see. In this case personally I would send a message
something like:

"Failed to connect to database. Please ensure you have entered the information correctly."

 
Mahesh Kumaraguru
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod karnani wrote:

how can I know user specified wrong ip address or port . It just throw above exception in both case (wrong ip address and wrong port )



A client application would not be able to know whether server is not running or ip address is wrong or port is wrong.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic