SmartPets Pro icon

SmartPets Pro -----

Pets That Think, Feel, and Live



MySQL Shared Database Compatibility Fix
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:
  1. MYSQL was missing from the PetDataHandler.StorageType enum
  2. MySQL driver URL was obsolete (Oracle changed the artifact ID)
  3. 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
:
  1. Foreign keys in MySQL require exact matching of charset, collation, and column types
  2. When using a shared database with other plugins, the players table might already exist with different charset/collation
  3. 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
  1. Stop your server
  2. 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;
  3. Replace SmartPets-2.0.1.jar with SmartPets-2.0.3.jar
  4. 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
  1. Stop your server
  2. Replace SmartPets-2.0.1.jar with SmartPets-2.0.3.jar
  3. Delete old driver if present: plugins/SmartPets/lib/mysql-connector-java-*.jar
  4. Start your server (new driver downloads automatically)
Note: No configuration changes required. Existing data is preserved.
----------, Jan 1, 2026
Resource Information
Author:
----------
Total Downloads: 24
First Release: Jun 5, 2025
Last Update: Mar 20, 2026
Category: ---------------
All-Time Rating:
1 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings