1. Tom has not to buy a book.

2. Tom doesn't have to buy a book.
(Are both the same? Is #1 wrong?)

Yes, # 1 is wrong.

2. is correct.