How to check if a particular database in mysql already exists using java

后端 未结 4 612
清酒与你
清酒与你 2020-12-09 11:00

I am new in JDBC and I wanted to find out if there is a way to check if a particular database already exists in MySQL.

Let\'s say I wanted to create a database named

4条回答
  •  悲哀的现实
    2020-12-09 11:40

    You're doing it back to front. The correct technique is to try to create it and catch the exception. The way you want to do it is subject to timing-window problems: it wasn't there when you tested, but it was there when you tried to create it. And you still have to catch the exception anyway.

提交回复
热议问题