Java tutorial
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.Statement; public class Main { private static final String DRIVER = "com.mysql.jdbc.Driver"; private static final String URL = "jdbc:mysql://localhost/testdb"; private static final String USERNAME = "root"; private static final String PASSWORD = ""; public static void main(String[] args) throws Exception { Class.forName(DRIVER); Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD); Statement statement = connection.createStatement(); String query = "SELECT stock_id, name, price FROM stocks"; ResultSet resultSet = statement.executeQuery(query); ResultSetMetaData metadata = resultSet.getMetaData(); int precision = metadata.getPrecision(3); int scale = metadata.getScale(3); System.out.println("Precision: " + precision); System.out.println("Scale : " + scale); } }