code: private static String getTypeName(int type, int length, ResultSet typeInfo) throws SQLException {
      int dataTypeColumn = typeInfo.findColumn("DATA_TYPE");
      while (typeInfo.next()) {
        if (typeInfo.getInt(dataTypeColumn) == type) {
          String typeName = typeInfo.getString("TYPE_NAME");
          if (length > 0) {
            if (typeName.contains("()")) {
              return typeName.replaceAll("\\(\\)", "(" + length + ")");
            } else {
              return typeName + "(" + length + ")";
            }
          } else {
            return typeName;
          }
        }
      }
      return null;
    }
docs: Gets the <code>String</code> denoting the specified SQL data type.
  @param type The data type to get the name of.  Valid type values
  consist of the static fields of {@link java.sql.Types}.
  @param length The length to assign to data types for those types
  that require a length (e.g., <code>VARCHAR(n)</code>), or zero
  to indicate that no length is required.
  @param typeInfo The <code>ResultSet</code> containing the type information
  for the database.  This must be obtained using
  {@link java.sql.DatabaseMetaData#getTypeInfo()}.
  @return The name of the type, or <code>null</code> if no such type
  exists.
  @throws SQLException If an error occurs while communicating with the
  database.
  @see java.sql.Types
  @see java.sql.DatabaseMetaData#getTypeInfo()