Log4j does not allow you to control logging based on class or package names per se. Rather, the granularity of logging control with log4j (and similar Java loggers) is determined by the logger names used by the application. If your JDBC driver has different loggers for statements, prepared statements, resultsets and so on, you are fine. However, if it uses a single logger for all of its logging, you would need to resort to some kind of filtering.
For more information, this page has a section on configuring filters in an XML Configuration file, and the Filter javadoc lists the available (standard) filter classes. For example, you can filter based on whether a logging event's message matches a given string.
Having said that, the filtering approach will be cumbersome, especially if there are lots of different messages to be filtered in / out.