Get string functions supported by database in Java
Description
The following code shows how to get string functions supported by database.
Example
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
/*from www .ja v a 2s. co m*/
public class Main {
public static void main(String[] args) throws Exception {
Connection connection = getConnection();
DatabaseMetaData metadata = connection.getMetaData();
String[] functions = metadata.getStringFunctions().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", "");
}
}