I am writing a module for Joomla, at this point I really need to be able to connect to the database using Jfactory. Normally one could simply use $db = JFactory::getDB
For accessing Database information of Joomla ,You should include("configuration.php").This joomla configuaraion file contains all information of database access.
class JFactory defined in this folder "joomlaRootFolder/libraries/joomla/factory.php"