@@ -0,0 +1,1624 @@
+package com.github.jcpp.jathenaeum.db;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0A%0Aimport javax.naming.Context;%0Aimport javax.naming.InitialContext;%0Aimport javax.naming.NamingException;%0Aimport org.apache.tomcat.dbcp.dbcp.BasicDataSource;%0A%0A/**%0A * Handle the connection with the database.%0A * @author %3Ca href=%22https://github.com/DavidePastore%22%3EDavidePastore%3C/a%3E%0A *%0A */%0Apublic class Database %7B%0A%09private static Database database = null;%0A%0A%09/**%0A%09 * Not instantiable.%0A%09 */%0A%09private Database() %7B%0A%09%7D%0A%0A%09/**%0A%09 * Return the singleton object.%0A%09 * @return%0A%09 */%0A%09public static Database getInstance() %7B%0A%09%09if (database == null)%7B%0A%09%09%09database = new Database();%0A%09%09%7D%0A%09%09return database;%0A%09%7D%0A%0A%09/**%0A%09 * Get the connection from the database.%0A%09 * @return%0A%09 */%0A%09public Connection getConnection() %7B%0A%09%09Connection con = null;%0A%09%09Context initCtx;%0A%09%09try %7B%0A%09%09%09initCtx = new InitialContext();%0A%09%09%09Context envCtx = (Context) initCtx.lookup(%22java:comp/env%22);%0A%09%09%09BasicDataSource ds = (BasicDataSource) envCtx.lookup(%22jdbc/JAthenaeum%22);%0A%09%09%09con = ds.getConnection();%0A%09%09%09System.out.println(%22##db## - 'Pooled Connection' acquisita.%22);%0A%09%09%7D catch (NamingException e1) %7B%0A%09%09%09e1.printStackTrace();%0A%09%09%7D catch (SQLException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09return con;%0A%09%7D%0A%0A%09/**%0A%09 * Close the connection with the database.%0A%09 * @param con%0A%09 */%0A%09public void closeConnection(Connection con) %7B%0A%0A%09%09try %7B%0A%09%09%09if (con != null) %7B%0A%09%09%09%09con.close();%0A%09%09%09%09System.out.println(%22##db## - Connessione rilasciata.%22);%0A%09%09%09%7D%0A%09%09%7D catch (SQLException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%09System.out.println(%22Errore durante la chiusura della connessione.%22+%0A%09%09%09%09%09e.getMessage());%0A%09%09%7D%0A%0A%09%7D%0A%0A%7D%0A

Add Database class.