import java.sql.*; /* mysql> desc iris; +-------------+------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+------------+------+-----+---------+-------+ | sepallength | double | YES | | NULL | | | sepalwidth | double | YES | | NULL | | | petallength | double | YES | | NULL | | | petalwidth | double | YES | | NULL | | | Class | mediumtext | YES | | NULL | | +-------------+------------+------+-----+---------+-------+ */ class example { public static void main (String[]args) { try { Class.forName ("org.gjt.mm.mysql.Driver"); } catch (Exception e) { System.out.println ("AAAA"); } Connection connection = null; Statement statement = null; ResultSet rs = null; ResultSetMetaData md = null; try { connection = DriverManager.getConnection ("jdbc:mysql:///aqq", "", ""); statement = connection.createStatement (); rs = statement.executeQuery("SELECT concat(Class,petallength), COUNT(*) FROM `iris` GROUP BY `concat(Class,petallength)`"); md = rs.getMetaData (); for (int i = 1; i <= md.getColumnCount (); i++) { System.out.println ("Column: " + md.getColumnName (i) + " SQLType: " + md.getColumnType (i)); // -4 is LONGVARBINARY!!! } rs = statement.executeQuery ("SELECT concat(Class,petallength) FROM `iris`"); md = rs.getMetaData (); for (int i = 1; i <= md.getColumnCount (); i++) { System.out.println ("Column: " + md.getColumnName (i) + " SQLType: " + md.getColumnType (i)); // 12 is VARCHAR - OK } statement.close (); connection.close (); } catch (SQLException ex) { System.out.println ("SQLException: " + ex.getMessage ()); System.out.println ("SQLState: " + ex.getSQLState ()); System.out.println ("VendorError: " + ex.getErrorCode ()); } } }