application.properties.
Database Configuration
The application connects to MySQL using these settings (fromapplication.properties):
Connection Issues
Connection refused errors
Connection refused errors
Error Message:Causes & Solutions:On macOS:On Windows:
- MySQL is not running:
- Wrong host or port:
- Verify MySQL is listening on port 3306:
- Firewall blocking connection:
- MySQL bound to wrong interface:
- Edit
/etc/mysql/mysql.conf.d/mysqld.cnf:
- Edit
- Restart MySQL after changes
Authentication failures
Authentication failures
Error Messages:Solutions:Or create
- Verify credentials:
- Default username:
root - Default password:
MCS_47_2006(as configured) - Test connection:
- Default username:
- Use environment variables (recommended for security):
.env file (DO NOT commit to git):- Reset MySQL root password:
- Authentication plugin issue:
The application uses environment variables with defaults. Set
DB_USERNAME and DB_PASSWORD environment variables to override defaults.Schema Issues
Table not found errors
Table not found errors
Error Message:Causes & Solutions:
- Database doesn’t exist:
- The connection URL includes
createDatabaseIfNotExist=true, but verify:
- The connection URL includes
- Tables not created by Hibernate:
- Check
application.properties:19:
- Check
- For fresh start, change to
createtemporarily (WARNING: deletes data):
- Then change back to
update
- Entity classes have errors:
- Check entity annotations:
@Entity,@Table(name="...") - Verify naming strategy in
application.properties:37:
- Check entity annotations:
- Manual table creation:
- Initial data not loaded:
- Verify
data.sqlexists atsrc/main/resources/data.sql - Check configuration:
- Verify
Column or field errors
Column or field errors
Error Messages:Solutions:
- Schema out of sync with entities:
- Force schema update:
- Restart application (Hibernate will recreate tables)
- Check entity field annotations:
- Verify physical naming strategy:
- With
PhysicalNamingStrategyStandardImpl, names are used as-is - Entity field
fieldName→ columnfieldName(notfield_name)
- With
Character Encoding Issues
UTF-8 encoding errors and special characters
UTF-8 encoding errors and special characters
Problems:
- Special characters (á, é, í, ó, ú, ñ, ü) display as �� or ?
- Error:
Incorrect string value: '\xC3\xBC...'
- Add charset to connection URL:
- Set database charset:
- Set table charset:
- Check column charset:
- Verify MySQL configuration:
- Edit
/etc/mysql/mysql.conf.d/mysqld.cnf:
- Edit
- Restart MySQL
- Add to application.properties:
Use
utf8mb4 instead of utf8 for full Unicode support, including emojis and special characters. This is especially important for “Iqüea” with the umlaut.Constraint Violations
Foreign key constraint failures
Foreign key constraint failures
Error Message:Causes & Solutions:
- Referenced record doesn’t exist:
- Trying to delete parent with existing children:
- Load order in data.sql:
- Ensure parent tables are populated before children
- Temporarily disable constraints (use carefully):
Unique constraint violations
Unique constraint violations
Error Message:Solutions:
- Check for existing records:
- Update instead of insert:
- Handle in application code:
Data too long for column
Data too long for column
Error Message:Solutions:
- Check column definition:
- Increase column size:
- Update entity annotation:
- Validate input length in application:
Performance Issues
Slow queries and N+1 problems
Slow queries and N+1 problems
Solutions:
- Enable SQL logging to identify slow queries:
- Use JOIN FETCH to avoid N+1:
- Add database indexes:
- Check query execution plan:
Diagnostic Commands
Useful commands for troubleshooting:Additional Resources
- Common Issues - General troubleshooting
- CORS Issues - Frontend-backend communication
- MySQL Documentation - Official MySQL docs