For you the best option is to not use Joomla Framework as it is very difficult to find any decent documentation/tutorials and you won't get much help about it.
You have to use normal Joomla CMS package. If your app connects from outside of the app, then the solution is to use an external PHP script that uses Joomla's functionalities. If users can visit your webapp, simple login and execute a script that connect's to an external app and show some data, then the best solution is to just a use a simple module, not component as it would make it too complex for such a simple task.
In both cases functions would be similar (I will paste code for an external script, in other case just stripe what is not needed):
<?php
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__)));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
$app = JFactory::getApplication('site');
$jinput = $app->input;
// $db = JFactory::getDbo(); This is simple local DB connect
// And this is for external connection
$option = array(); //prevent problems
$option['driver'] = 'mysql'; // Database driver name
$option['host'] = 'db.myhost.com'; // Database host name
$option['user'] = 'mysqluser'; // User for database authentication
$option['password'] = 'anduserspassword'; // Password for database authentication
$option['database'] = 'nameofthedatabase'; // Database name
$option['prefix'] = 'iypow_'; // Database prefix (may be empty)
$db = JDatabaseDriver::getInstance($option);
$user_login = $jinput->getString('user_login', '');
$user_password = $jinput->getString('user_password', '');
// use $app->login(array($user_login, $user_password)) to login user
// https://api.joomla.org/cms-3/classes/JApplicationCms.html#method_login
// if (user is logged in) {
// then connect to an external DB
// Simple query in Joomla's way
// for more infomration how to fetch data see
// https://docs.joomla.org/Selecting_data_using_JDatabase
$query = $db->getQuery(true);
$query
->select($db->quoteName('*'))
->from($db->quoteName('#__mytable'))
->where($db->quoteName('user') . ' = ' . $db->quote($user_login));
$db->setQuery($query);
$user = $db->loadObject();
print_r($user);
// }
?>