Here you can find the source of getDBProduct(Connection conn)
public static String getDBProduct(Connection conn)
//package com.java2s; //License from project: Open Source License import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { private static final String DATABASE_REGEX = ".*(db2|oracle|mysql|sql server|hive|asterdata|gbase|postgresql).*"; public static String getDBProduct(Connection conn) { DatabaseMetaData metaData = null; String result = ""; try {/*ww w .j a va 2s .c om*/ metaData = conn.getMetaData(); String driverName = metaData.getDriverName(); Pattern pattern = Pattern.compile(DATABASE_REGEX); Matcher m = pattern.matcher(driverName.toLowerCase()); if (m.matches()) { result = m.group(1).replace(" ", ""); } if ("".equals(result)) { result = "asterdata"; } } catch (SQLException e) { e.printStackTrace(); } return result; } }