Fixed validation query for derby databases