Stored Procedure Names in a database using java

Retrieves the names of all stored procedures in a database.

try {
// Get database metadata
DatabaseMetaData dbmd = connection.getMetaData();

// Get all stored procedures
ResultSet resultSet = dbmd.getProcedures(null, null, "%");

// Get stored procedure names from the result set
while (resultSet.next()) {
String procName = resultSet.getString(3);
}

} catch (SQLException e) {
System.out.println(e);
}

Round double value using java

You can round a double using the setScale() method of BigDecimal class.

public double round(double d, int decimalPlace) {

BigDecimal bd = new BigDecimal(Double.toString(d));

bd = bd.setScale(decimalPlace, BigDecimal.ROUND_HALF_UP);

return bd.doubleValue();

}