Here is the code to implement it..
//Creating an object of servicefactory class
theServiceFactory = createObject('java','coldfusion.server.ServiceFactory');
//Creating the connection object simply by passing the DSN name
con = theServiceFactory.getDataSourceService().getDataSource('DataSource Name').getConnection();
//Now passing the connection object as argument to the test.java class
testConnection = createObject('java', 'namespace to code').init(con );
Hope this will help you..Keep coding :)