You can try replacing the newline character with break tag before insterting it into the database.