If you need any extra library in a selenium java class, you need to add it to the dependencies of you pom.xml file. Here is an example on how to add a jdbc and a db2 driver which are used in a java class :
pom.xml
<!-- Here you can add libraries to the engine classpath, using the <dependencies></dependencies>
tag -->
<!-- A sample with the mySql jdbc driver -->
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.19</version>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc3</artifactId>
<version>10.5</version>
</dependency>
</dependencies>