Get numeric functions supported by database in Java

Description

The following code shows how to get numeric functions supported by database.

Example


import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
//from ww  w . j a  v a 2 s . c  o  m
public class Main {
  public static void main(String[] args) throws Exception {
    Connection connection = getConnection();
    DatabaseMetaData metadata = connection.getMetaData();

    String[] functions = metadata.getNumericFunctions().split(",\\s*");

    for (int i = 0; i < functions.length; i++) {
      String function = functions[i];
      System.out.println("Function = " + function);
    }
    connection.close();
  }

  private static Connection getConnection() throws Exception {
    Class.forName("org.hsqldb.jdbcDriver");
    String url = "jdbc:hsqldb:mem:data/tutorial";

    return DriverManager.getConnection(url, "sa", "");
  }
}




















Home »
  Java Tutorial »
    JDBC »




Batch
Binary Data
Database
Date Time
Insert
ResultSet
SQL
Statement
Stored Function
Table