If you can't root the phone, flash the phone with g310hnxxu0anda oxx0and5 firmware version than root it with Kingo Root.
UNLOCK INSTRUCTIONS:
Phone must be rooted!
If the software can't root the phone automatically,
then you must root your device manually.
1. Power on the phone.
2. Enable 'USB debugging' in 'Settings'-'Developer options' for Android 4.0 - 4.1.2 or
tap 7 times on 'Build number' in 'Settings'-'About phone' to enable 'Developer options' in Android 4.2+.
3. Connect the phone to PC with USB cable, install drivers if needed.
4. Press 'Unlock' button for direct unlock or 'Read codes' to read security codes.
Operation: Unlock
Selected model: SM-G310HN
Software version: 21.0
Waiting ADB device...
Please, allow USB debugging on phone... OK
Reading phone info...
Model: SM-G310HN
Android version: 4.4.2
Product code: SM-G310HZWNDBT
Phone version: G310HNXXU0ANDA
PDA version: G310HNXXU0ANDA
CSC version: G310HNOXX0AND5
CSC country code: Germany
CSC sales code: DBT
HW version: MP 0.300
Phone S/N: R21FA12RK6F
Modem board:
RF cal date: 20141010
IMEI: 352215063722878
Checking Super user right... true
Reading data from phone... OK
Unlocking... OK
Rebooting phone... OK
Unlock done
Done with Samsung Tool PRO v.21.0
UNLOCK INSTRUCTIONS:
Phone must be rooted!
If the software can't root the phone automatically,
then you must root your device manually.
1. Power on the phone.
2. Enable 'USB debugging' in 'Settings'-'Developer options' for Android 4.0 - 4.1.2 or
tap 7 times on 'Build number' in 'Settings'-'About phone' to enable 'Developer options' in Android 4.2+.
3. Connect the phone to PC with USB cable, install drivers if needed.
4. Press 'Unlock' button for direct unlock or 'Read codes' to read security codes.
Operation: Unlock
Selected model: SM-G310HN
Software version: 21.0
Waiting ADB device...
Please, allow USB debugging on phone... OK
Reading phone info...
Model: SM-G310HN
Android version: 4.4.2
Product code: SM-G310HZWNDBT
Phone version: G310HNXXU0ANDA
PDA version: G310HNXXU0ANDA
CSC version: G310HNOXX0AND5
CSC country code: Germany
CSC sales code: DBT
HW version: MP 0.300
Phone S/N: R21FA12RK6F
Modem board:
RF cal date: 20141010
IMEI: 352215063722878
Checking Super user right... true
Reading data from phone... OK
Unlocking... OK
Rebooting phone... OK
Unlock done
Done with Samsung Tool PRO v.21.0