The iPhone memory is non-volatile flash, which means that you won't lose data by disconnecting (or completely draining) the battery.
However, you should *still* do a full backup before attempting any repair or sending in a device for service. For non-jailbreak iPhones, the iTunes backup is very complete.
For jailbreak phones, install AppBackup from Cydia and follow its backup instructions, then backup using iTunes. If you need to restore, you'd have to re-jailbreak, install AppBackup, restore from iTunes, then restore your jailbreak apps using AppBackup's restore features.