Use the mysql-connector from yum/apt-get. Add /usr/share/java to the classpath and switch to hdfs only if the uid exists.