Unfortunately the Dualshock 3 Does not work with the PS4. While it is techincally possible to use a Dualshock 3 with the PS4 it is not something that Sony currently allow us to do. This may be due to the requirement of hardware features that are specific to the Dualshock 4. The Dualshock 4 contains the touch pad, speaker and mic jack that the Dualshock 3 does not have.
On the other hand, it is possible to use a Dualshock 4 controller with the PS3.