This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
You are probably getting the DS on the first try and assigning the connection when the DS is not null on the second try. The second call probably does not return null, but we can only speculate since the code and the problem at hand do not match each other