java.sql.SQLException: Before start of result set [duplicate]

Solution 1:

You must call rs.next() (and check that it returns true) to access the first row of the result set:

if (rs.next() {
    InputStream stream = rs.getBinaryStream(1);
    ...

Also not that the index should be 1, since your query only selects one column.

I also don't understand the point in casting the int to a char. The method takes an int as argument. A cast to byte would at least be logical, but bytes and char are not the same thing in Java.

Solution 2:

If you execute the select query, you will get a ResultSet object. Iterate through it and you won't get this exception.

  ResultSet rs = null;
  rs = statement.executeQuery("select UUID_BINARY()");

        if(rs.next()){

            newTripUUID = rs.getBytes(1);

        }