[solved] Global.conf and MySQL

[Scroll to the bottom for the solution]
I’m having issue with my global.conf now.
during startup I get

Sat May 13 13:18:18 EAST 2017 - Server is starting now!
[a bunch of other token and hook lines]
[13:18:30] [main/ERROR] [Sponge]: Failed to load configuration
java.io.IOException: configurate.typesafe.config.ConfigException$Parse: Reader: 262: Key ‘“jbdc:mysql://db516380:(password removed)@sql-7.verygames.net/db516380”’ may not be followed by token: ‘}’ (if you intended ‘}’ to be part of a key or string value, try enclosing the key or value in double quotes)

Followed by about 142 kb (142,226 b) worth of errors in the console by the time it stops. I can provide a console log if needed.

My sql section of the global.conf looks like this as of the typing of this post:

sql {
# Aliases for SQL connections, in the format jdbc:protocol://[username[:password]@]host/database
aliases {
“jbdc:mysql://db516380:(password removed)@sql-7.verygames.net/db516380”
}
}

It worked before I updated but I didn’t save the file for reference. Do I need to remove the brackets?
Using Forge 1.10.2-12.18.3.2297
The only thing in my mods folder
SpongeForge 5.2.0 build 2320 for Forge 2281

Yes. Braces around a single value is invalid HOCON.

Removing the brackets didn’t change anything
I tried with and without the brackets

aliases "jbdc:mysql://db516380:(password)@sql-7.verygames.net/db516380"

With and without the quotes

aliases { jbdc:mysql://db516380:(password)@sql-7.verygames.net/db516380 }

And various combinations of both

aliases { "jbdc:mysql://db516380:(password)@sql-7.verygames.net/db516380" }

The current global.conf as of the typing of this reply

sql {
# Aliases for SQL connections, in the format jdbc:protocol://[username[:password]@]host/database
aliases “jbdc:mysql://db516380:(password)@sql-7.verygames.net/db516380”
}

and the error I got is

java.io.IOException: configurate.typesafe.config.ConfigException$Parse: Reader: 261: Key ‘aliases “jbdc:mysql://db516380:(password)@sql-7.verygames.net/db516380”’ may not be followed by token: ‘}’ (if you intended ‘}’ to be part of a key or string value, try enclosing the key or value in double quotes)
(followed again by a few hundred kb worth of errors. hastebin available if requested)

I don’t even have a bracket on it.
I’m going to try one more time. I will remove the config folder, load once to regen a new one, and try without “aliases” in there.

Edit
Not sure if it’s relevant, but it replaces my global.conf with default and restarts the server.

Edit 2
I saved a step by just changing the line in the config.

Just for anyone else that has a similar issue, replace the default aliases { } with aliases=jbdc:protocal://username:password@host/database

Again, this is a HOCON syntax problem. You need an = between a key and a value, unless the value is an object.

It appears the global.conf keeps resetting the sql alias back to default, and I don’t know why. There are no errors in the console.

I keep changing it to connect to my database and it keeps going back to default.

Edit:
I’m wondering if it has anything to do with timings.hidden-config-entries Is there a way to set that to my database?

I will post a ticket to the Github when I wake up, if nothing is posted here before that.

It’s JDBC not JBDC

1 Like

I realized that mistake since I started this post, but even after fixing that I still have the issue of the sql alias resetting.
Github issue

It’s because the section is intended to hold aliases to connection strings, so that in plugins that use the SqlService, you can just specify the alias to connect to, rather than the full jdbc string.

So, the actual format would be:

# Configuration options related to the Sql service, including connection aliases etc
sql {
    # Aliases for SQL connections, in the format jdbc:protocol://[username[:password]@]host/database
    aliases {
        name="jdbc:protocol://db516380:(password)@sql-7.verygames.net/db516380",
        differentname="some database other string"
    }
}

Configurate essentially sees an invalid entry and overwrites it with it’s own default.

Plugins can then use SqlService#getConnectionUrlFromAlias(name) to get an optional containing the alias in question, if it exists.

I’ll agree with you though, it’s not obvious from the documentation we have.

2 Likes

That helped. I now have all three of my databases on the list. I’m just not sure if there are any plugins/mods out there that implement the SqlService like you mentioned.