-2

I have a SQL database in a Gridgain cache and one column of that database is a short array.

Column name Data type
Order Id Integer
Timestamp Long
Activity Short []

My SQL query is like this. String sql = "Select activity from cache where orderId = ? and timestamp <= ? and timestamp >= ? "; I am executing following java code. Since I am not sure about the return data type I assigned the return value to an object and printed its type. result was

XX [S@3eb7630d XX type class [S

Code is

Object xx = null;
List<Short> activityList = new ArrayList<>();
try (QueryCursor<List<?>> cursor = patientTriggerCache.query(sql)) {
                    for (List<?> row : cursor) {
                        xx = row.get(0);
                        activityList.add((short) xx);
                    }
                }

error is

java.lang.ClassCastException: [S cannot be cast to java.lang.Short

sachith
  • 129
  • 2
  • 12

1 Answers1

3

[S is the runtime signature of an array of integers of type short (the primitive type, not java.lang.Short). The run time signature of an array of integers of type int would be [I.

    short x[] = new short[10];
    System.out.println("Hello "+x);

The output is Hello [S@6d06d69c.

As correctly noted by @Jon Skeet in comment, these names can be found here.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93