Get up and running quickly
This quickstart guide will help you run the H2 database enterprise management system and perform your first database operations.Or manually download from the H2 Database website.
Archivo de BD anterior eliminado: db_empresa_h2.mv.db
Creando base de datos H2...
Base de datos H2 en memoria creada exitosamente!
=== GESTIÓN EMPRESA (H2) ===
1. Ver empleados
2. Agregar empleado
3. Buscar empleados
4. Ver departamentos
5. Eliminar empleado
6. Información completa con JOINs
7. Salir
Elige:
Understanding the Application
The application demonstrates key JDBC concepts:Database Schema
Three interconnected tables:
t_centros (centers), t_departamentos (departments), and t_empleados (employees)CRUD Operations
Full Create, Read, Update, Delete functionality with PreparedStatements for security
JOIN Queries
Complex queries combining employee, department, and center information
H2 File Database
Persistent file-based database that survives application restarts
Key Code Snippets
Database Connection
The application uses H2’s file-based database with auto-server mode:DB_EnterpriseH2.java:7-9
PreparedStatement for Security
All user inputs use PreparedStatements to prevent SQL injection:DB_EnterpriseH2.java:220-226
Multi-table JOIN Query
Retrieving complete employee information across three tables:DB_EnterpriseH2.java:260-272
Next Steps
Installation Guide
Detailed setup instructions for Java and database drivers
Database Configuration
Learn about config.ini and connection settings
CRUD Operations
Deep dive into database operations
HSQLDB Setup
Try the alternative HSQLDB implementation
Troubleshooting
ClassNotFoundException: org.h2.Driver
ClassNotFoundException: org.h2.Driver
Make sure the H2 JAR file is in your classpath when compiling and running:
Database file locked
Database file locked
If you see locking errors, ensure no other process is using the database. The
AUTO_SERVER=TRUE parameter helps multiple connections, but the app recreates the DB on startup.Compilation errors
Compilation errors
Ensure you’re using Java 8 or higher: