简体   繁体   中英

How to get the db status using java?

I am new to the java programing and trying to develop an application. On my jsp page I am allowing user to enter the db details and then click on test button to check whether connection is set or not.

You can catch the SQLException from DriverManager.getConnection(). By this you can validate the connection.

If there is no Exception occurred while connecting with the given database details
you can tell connection is success.Else catch the exception and show message accordingly to the user

您可以使用jdbc触发"select 1"查询,并且如果没有引发任何异常,则可以说连接已完成。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM