I believe that "G 17" refers to the Model 17 standard (aka full-size) 9 mm semi-automatic pistol made by Glock. http://www.glock.com/english/index_pistols.htm
Assuming one can hit them, it works well on people and small game, but will only get a bear's undivided attention directed your way. Why would you want to get a bear's undivided attention?
It is widely believed by those who should know that if you shoot a black bear (but don't kill it immediately), the odds are about 50/50 that it will charge rather than run away. With a grizzly, that's an open invitation to, and a virtual 100% guarentee of, a charge, and he'll keep coming until one of you is dead.
As has very wisely been suggested by another poster, if you are fearful of people and/or bears where you're hiking, consider hiking somewhere else. The best way to avoid trouble is to be someplace else when it appears. Another poster correctly mentioned that bear spray will also discourage/disable a human attacker, allowing you to get away.
If you MUST carry a firearm for your peace of mind, be SURE you know your duties under the laws regarding both the use of deadly force and what constitutes brandishing. If you do use deadly force against someone, you'll have to convince a jury that you met all of those requirements before you fired and that under the same conditions, EACH ONE of them would have done the same thing.