Correct handling of return data
- by Serhiy
Hello,
I have a question related to correct handling of returns of the DAO library I'm writing for one project. This library probably is going to be used by another people and I want to do it correctly. So I would like to know, how I should deal with return statements of the functions of my DAO.
Example 1
I have function to getCustomer which should return String. In case query doesn't return any result should I return null, empty string or throw some kind of Exception?
Example 2
I have function getCutomerList which return ArrayList. In case query doesn't return any result should I return null, empty ArrayList or throw some Exception?
Example 3
Some sql exception was detected, what should I do: throw exception or do try..catch of the block where it can occur?
What is the "good" practice or "best" practice to apply in my case?
Thanks on advance,
Serhiy.