SmartPets v2.0.3 - MySQL Storage Fix
Release Date: 2026-01-01
Type: Bug Fix Release
Priority: HIGH
Bug Fixes
Critical: MySQL Storage Not Working
Problem: Users could not use MySQL storage. The plugin showed Invalid storage type 'MYSQL' and fell back to YAML.
Root Causes:
- MYSQL was missing from the PetDataHandler.StorageType enum
- MySQL driver URL was obsolete (Oracle changed the artifact ID)
- PetDataHandler was not integrated with the database storage system
Solution:
- Added MYSQL to the storage type enum
- Updated MySQL driver from deprecated mysql-connector-java-8.0.33 to mysql-connector-j-8.4.0
- Integrated DatabaseManager and DatabasePetStorage into PetDataHandler
- Added automatic fallback to YAML if database connection fails
Critical: MySQL Foreign Key Constraint Error (errno: 150)
Problem: Users with MySQL storage in shared databases got the following error:
Code (YAML):
[SmartPets] Failed to initialize database
: Can't create table `game_global`.`pets`
(errno
: 150
"Foreign key constraint is incorrectly formed"
)
Root Causes:
- Foreign keys in MySQL require exact matching of charset, collation, and column types
- When using a shared database with other plugins, the players table might already exist with different charset/collation
- MySQL's foreign key validation is stricter than SQLite's
Solution:
- Removed foreign keys from MySQL tables - Referential integrity is now enforced at application level
- Added table name prefixes for MySQL: smartpets_players, smartpets_pets, smartpets_pet_stats, smartpets_pet_skills
- Explicit ENGINE=InnoDB and utf8mb4 charset for maximum compatibility
- SQLite retains foreign keys as it handles them without issues
Why This Works:
- Prefixed table names avoid conflicts with other plugins using the same database
- Removing FK constraints eliminates charset/collation/type mismatches
- Application-level integrity validation is a common pattern in Minecraft plugins
- Same data integrity, but works in all MySQL configurations
Migration Notes
For New Installations
- No action required, tables are created with correct structure automatically
For Existing MySQL Users with errno 150
- Stop your server
- Option A (Recommended): Drop the failed SmartPets tables:
Code (YAML):
DROP TABLE IF EXISTS pet_skills;
DROP TABLE IF EXISTS pet_stats;
DROP TABLE IF EXISTS pets;
DROP TABLE IF EXISTS players;
- Replace SmartPets-2.0.1.jar with SmartPets-2.0.3.jar
- Start your server (new prefixed tables will be created)
For Existing MySQL Users WITHOUT Errors
- Data migration from old table names is NOT automatic
- If you had working MySQL storage, keep using v2.0.2 OR migrate data manually:
Code (YAML):
-- Only if upgrading from working v2.0.1 to v2.0.3
RENAME TABLE players TO smartpets_players;
RENAME TABLE pets TO smartpets_pets;
RENAME TABLE pet_stats TO smartpets_pet_stats;
RENAME TABLE pet_skills TO smartpets_pet_skills;
Compatibility
Environment
Status
MySQL 5.7+ Fully supported
MySQL 8.0+ Fully supported
MariaDB 10.3+ Fully supported
Shared databases Fully supported (prefixed tables)
SQLite Unchanged (full FK support)
YAML Unchanged
What Changed for End Users
- MySQL now works in shared databases without conflicts
- No configuration changes needed - same storage-type: "MYSQL" setting
- Data structure unchanged - same columns, just different table names for MySQL
- SQLite users unaffected - same behavior as before
Upgrade Instructions
- Stop your server
- Replace SmartPets-2.0.1.jar with SmartPets-2.0.3.jar
- Delete old driver if present: plugins/SmartPets/lib/mysql-connector-java-*.jar
- Start your server (new driver downloads automatically)
Note: No configuration changes required. Existing data is preserved.