Added exception throwing in case of Unique constraint violation
Added fix for encoding issue due to incorrect buffer length