Java connecting to multiple databases

前端 未结 2 1865
既然无缘
既然无缘 2021-01-14 08:18

I am creating a java application that connects to multiple databases. A user will be able to select the database they want to connect to from a drop down box.

The p

2条回答
  •  孤街浪徒
    2021-01-14 09:02

    You're catching JNDI exception upon lookup of the nonexistent datasource but your singleton still keeps the reference to previously looked up datasource. As A.B. Cade says, null reference to ds upon exception, or even before that.

    On a more general note, perhaps using Singleton is not the best idea.

提交回复
热议问题