We report the detection of 21-cm and H2 absorption lines in the same DLA system (log N(HI)=21.36+-0.10) at zabs=3.17447 towards SDSSJ133724+315254 (z=3.174). We estimate the spin temperature of the gas to be, Ts~600 K, intermediate between the expected values for cold and warm neutral media. This suggests that the HI absorption originates from a mixture of different phases. The total molecular fraction is low, f=10^-7, and H2 rotational level populations are not in equilibrium. The average abundance of the alpha-elements is, [S/H]=-1.45. N and Fe are found underabundant with respect to alpha-elements by ~1.0 dex and ~0.5 dex respectively. Using photoionization models we conclude that the gas is located more than 270 kpc away from the QSO. While the position of 21-cm absorption line coincides with the H2 velocity profile, their centroid are shifted by 2.7+-1.0 km/s from each other. However, the position of the strongest metal absorption component matches the position of the 21-cm absorption line within 0.5 km/s. From this, we constrain the variation of the combination of fundamental constants x=alpha^2 Gp/mu, Delta x/x=-(1.7+-1.7)x10^-6. This system is unique as we can at the same time have an independent constrain on mu using H2 lines. However only Werner band absorption lines are seen and the range of sensitivity coefficients is too narrow to provide a stringent constraint: Delta mu/mu <= 4.0x10^-4. The VLT/UVES spectrum reveals another DLA at zabs=3.16768 with log N(HI)=20.41+-0.15 and low metallicity, [Si/H]=-2.68+-0.11. We derive log N(DI)/N(HI)=-(4.93+-0.15) in this system. This is a factor of two smaller than the value expected from the best fitted value of Omega_b from the WMAP 5 yr data. This confirms the presence of astration of deuterium even at very low metallicity. [abridged]