Overview
TheDB_EnterpriseHSQLDB class is a complete enterprise database management system using HSQLDB. It provides a menu-driven interface for managing employees, departments, and centers with full CRUD (Create, Read, Update, Delete) operations.
Class Information
DB_EnterpriseHSQLDBJDBC Driver:
org.hsqldb.jdbc.JDBCDriverDatabase Constants
Database connection URL (loaded from config.ini)Default format:
jdbc:hsqldb:file:{database.path};shutdown=true;hsqldb.lock_file=falseDatabase username constant
Database password (empty by default)
Main Method
Signature
Workflow
Core Methods
cargarConfiguracion()
Purpose
Loads or creates the database configuration file (
config.ini)Configuration Details
Configuration Details
- Creates
config.iniif it doesn’t exist - Default property:
database.path = ./db_empresa - Constructs JDBC URL with shutdown and lock file settings
inicializarBaseDatos()
Purpose
Initializes the database by checking if tables exist and creating the schema if needed
Implementation
Implementation
crearEsquemaCompleto()
Active database connection
Tables Created
t_centros- Work centers/locationst_departamentos- Departments with foreign key to centerst_empleados- Employees with foreign key to departments
Schema Structure
Schema Structure
menuPrincipal()
- Ver empleados
- Agregar empleado
- Buscar empleados
- Ver departamentos
- Eliminar empleado
- Información completa con JOINs
- Salir
CRUD Operations
verEmpleados()
SQL Query
SQL Query
agregarEmpleado()
- Código (Employee ID)
- Departamento (Department ID)
- Nombre (Name)
- Salario (Salary)
- Fecha ingreso (Hire Date in YYYY-MM-DD format)
Implementation
Implementation
buscarEmpleados()
Partial name matching using LIKE operator
SQL Query
SQL Query
verDepartamentos()
Displays
Department ID, Name, and Budget for all departments
eliminarEmpleado()
Employee code to delete
Implementation
Implementation
informacionCompletaJoins()
Purpose
Displays complete employee information with department and center data using JOINs
Complex JOIN Query
Complex JOIN Query
Sample Data
The schema includes initial data:Centers
Centers
- Code 10: SEDE CENTRAL (C/ ALCALA, 820, MADRID)
- Code 20: RELACION CON CLIENTES (C/ ATOCHA, 405, MADRID)
Departments
Departments
- 100: DIRECCION GENERAL
- 110: DIRECCION COMERCIAL
- 111: SECTOR INDUSTRIAL
- 112: SECTOR SERVICIOS
- 120: ORGANIZACION
- 121: PERSONAL
- 122: PROCESO DE DATOS
- 130: FINANZAS
Employees
Employees
Six employees with complete data including:
- PONS, CESAR (Code: 110)
- LASA, MARIO (Code: 120)
- TEROL, LUCIANO (Code: 130)
- PEREZ, JULIO (Code: 150)
- AGUIRRE, AUREO (Code: 160)
- PEREZ, MARCOS (Code: 180)
Error Handling
Related Classes
- DB_Enterprise - Basic configuration manager
- DB_EnterpriseH2 - H2 database implementation