package org.kodejava.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
public class MaxConcurrentConnection {
private static final String URL = "jdbc:mysql://localhost/kodejava";
private static final String USERNAME = "root";
private static final String PASSWORD = "";
public static void main(String[] args) {
try (Connection connection =
DriverManager.getConnection(URL, USERNAME, PASSWORD)) {
DatabaseMetaData metadata = connection.getMetaData();
// Get the information of maximum concurrent connection to the
// database. The maximum number of active connections possible
// at one time; a result of zero means that there is no limit
// or the limit is not known.
int maxConnection = metadata.getMaxConnections();
System.out.println("Maximum Connection = " + maxConnection);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
The result of the code snippet above:
Maximum Connection = 0
Maven dependencies
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
</dependency>
Latest posts by Wayan (see all)
- How do I build simple search page using ZK and Spring Boot? - March 8, 2023
- How do I calculate days between two dates excluding weekends and holidays? - January 12, 2023
- How do I discover the quarter of a given date? - January 11, 2023