DB connection part of API or a separate Plugin?

I have a list of potential options here:

Unfortunately none of them really fit all the necessary criteria and we are not in a position to write an entire persistence ecosystem ourselves.

1 Like

While talking with @coelho in #permissionsex, we came up with a quick proposal for how Sponge could handle sharing basic JDBC connections between plugins. There could always be some sort of ORM on top of this, but this would help plugins take care of basic connection management.

17:56 @zml sponge was considering including a connection pool impl
17:56 coelho from how jdbc is implemented it is possible
17:56 coelho but they need to remember that someone might be using multiple DBs in different plugins.
17:57 @zml well, it would just shade the pool library into the API jar, then plugins would access it like normal
17:57 coelho I would like it if the connection pool was actually shared between plugins
17:57 coelho because what I see atm is that a mysql server for bukkit normally has a ridiculous amount of connections from other plugins and their own pools
17:57 coelho basically wasting resources on the sql server
17:58 @zml that could work, database connections configured in-api, then plugins acess those database connections (by name?)
17:58 coelho I would assume they would access it by driver, connection string, username, and password
17:58 coelho Or maybe there could be a config
17:59 coelho So it’s just driver and name of connection
17:59 coelho Streamline it a little bit more.
17:59 @zml could be like the JBDC URL
17:59 coelho well if we do it this way
17:59 @zml just jdbc:mysql://user:pass@host/database
17:59 coelho what we can have is a config in the main server directory with one sql config
17:59 @zml brb
17:59 coelho and then all plugins just reference it by name
17:59 coelho so you don’t have to c&p the same sql config into a thousand plugins.

Yes, your last point being the crux of the matter

DB connection would be so good to have by default!!

Some sort of ORM (Object relational mapping) system would be really nice.

1 Like