Can't get DB to connect as data source in CF Admin for CB CF11 Server

I have a Commandbox server running the ACF11 engine (much thanks to @jclausen for helping me on that). If relevant, I had to add a setting in server.json to get the server to start:
"JVM":{"javaVersion":"openjdk8"}

My problem is that in the CF Admin, I’m trying to connect a MySQL DB as a data source, and it’s failing with the below information:
“Connection verification failed for data source: foo_mysql5
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
The root cause was that: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.”

I’ve been able to connect the same DB as a datasource for another CB server I have (which is running CF2016) with no problems. The driver is the same (MySQL 5), username and password are the same, and host is the same (127.0.0.1).

Any help getting it to work is much appreciated. Sticking with the CF11 engine would be ideal, since this is for a dev environment I’m trying to set up on my local machine for a client running CF11 on their live site.

Can you please capture the FULL stack trace, including all CAUSED BY exceptions at the bottom?

Apologies, I’m not sure how to get that. This is the message I’m seeing in the CF Admin “Data Sources” page when I click “submit” or the “verify” icon for the data source.

  • check the logs
  • Don’t verify the datasource and simply hit a page that uses it

Below is what’s in the exception log:

“Error”,“XNIO-1 task-1”,“06/01/23”,“11:50:35”,“Could not create connection to database server. Attempted reconnect 3 times. Giving up.”
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:395)
at com.mysql.jdbc.Util.getInstance(Util.java:370)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:999)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:959)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:904)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2369)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2290)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:818)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:395)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
at coldfusion.server.j2ee.sql.pool.JDBCPool.createPhysicalConnection(JDBCPool.java:614)
at coldfusion.server.j2ee.sql.pool.ConnectionRunner$RunnableConnection.run(ConnectionRunner.java:67)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharacterEncoding(ConnectionImpl.java:3260)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1940)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1866)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1252)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2467)
at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2308)
… 13 more

There is the “real” error :slight_smile: When it comes to JDBC errors, you always have to find the very bottom root cause as the rest are just wrappers around another exception.

Now, google that error. Here is a promising SO post:

Thanks! I noticed that NullPointerException, and it made me wonder if the problem’s similar to what I was experiencing when trying to get the CF11 Server to run - i.e., that it’s expecting a .jar file that no longer exists in the JDK.

After reading the SO post, and considering the success I’ve had connecting with newer versions of CF, it makes me wonder if the problem isn’t that the CF11 Admin is expecting an older version of the MySQL Driver than I have, especially since I had to set the Java version to “openjdk8” in server.json. In which case, I’d think getting the latest MySQL driver (8.0.33) won’t help. Is there a way to check what version of the MySQL driver I currently have, and might there be another setting I should put in my server.json file?

Thanks - I’m trying to think this through on my own steam, but the way forward isn’t clear yet…

P.S. - Just found the answer to my first question, after looking at “Downgrade mysql-connector-java - #2 by bdw429s”. Looking in cfusion/lib for that CF11 server, I see the MySQL connector I have is mysql-connector-java-commercial-5.1.25-bin.jar. Still unsure how to proceed though - do I want to replace that with a different driver?)

@bdw429s I’ve thought on this some more, please let me know if I’m on the right track. I’m thinking, the MySQL DB on my machine can only be connected to by a more up-to-date connector than that CF11 server has. The current connector in the CF11 server’s cfusion/lib folder is “mysql-connector-java-commercial-5.1.25-bin.jar”. I’m running MySQL 8 on my machine, so that’s a pretty glaring sign that that connector is too old.

I’ve downloaded a copy of the most up-to-date connector, “mysql-connector-j-8.0.33.jar”. I imagine this needs to replace the existing connector in cfusion/lib. But is it as simple as just removing the old driver and pasting the new one?

No clue man, lol. Try it and see. I have no idea if the newer drivers are backwards compat to just drop them in, but there’s a fighting chance it works as the JDBC spec hasn’t changed in a while. This really isn’t a CommandBox question any longer, so you may find someone with more info on the #adobe channel of the CFML Slack team. I haven’t used Adobe CF 11 in many, many years and I’ve never tried to connect it to a MySQL 8 instance.

For clarification, what is running on your local machine, what is on a separate server/workstation. You mentioned a CF2016 server, the CF11 you’re trying to get working, MySQL 5, and MySQL 8.

Okay, thanks. Yeah, I did try that, and it didn’t work; I just got a different error message. I just now did what I should have done first, which is look in the cfusion/lib of the server that IS connecting, and see what the MySQL connector jar file is. Turns out it’s “mysql-connector-java-8.0.25.jar”, which isn’t the same .jar file I just tried with (mysql-connector-j-8.0.33.jar). I’m still not certain if .jar files can just be arbitrarily added/removed from that cfusion/lib folder, or if they need to be installed/registered/etc.

I’ll try a copy of that mysql-connector-java-8.0.25.jar file and see if I have any luck with that.

Everything is on my local machine. The CF2016 server is through CommandBox, as is the CF11 server. I have MySQL 8.0 running on my machine, as well. With both servers, in their respective CF Admins, I’m trying to add that DB as a data source, specifying the “MySQL 5” driver from the dropdown (since the only other option for MySQL is “MySQL (DataDirect)”). The CF2016 server can connect to the DB as a data source with no problems. The CF11 server can’t, and is giving a NullPointerException error.

All right, for posterity – I tried replacing the old driver in cfusion/lib with mysql-connector-java-8.0.25.jar, and got the same error message as when I tried it with 8.0.33 (below). I think I may just have to use a later CF Engine than CF11 for my development environment, or see if I can get an earlier version of MySQL running on my machine.

Stack Trace:
"com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:833)
at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:453)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at coldfusion.server.j2ee.sql.pool.JDBCPool.createPhysicalConnection(JDBCPool.java:614)
at coldfusion.server.j2ee.sql.pool.ConnectionRunner$RunnableConnection.run(ConnectionRunner.java:67)
at java.lang.Thread.run(Thread.java:750)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:342)
at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:203)
at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1353)
at com.mysql.cj.NativeSession.connect(NativeSession.java:157)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
… 6 more
Caused by: javax.net.ssl.SSLHandshakeException: Could not generate secret
at sun.security.ssl.ECDHKeyExchange$ECDHEKAKeyDerivation.t13DeriveKey(ECDHKeyExchange.java:479)
at sun.security.ssl.ECDHKeyExchange$ECDHEKAKeyDerivation.deriveKey(ECDHKeyExchange.java:419)
at sun.security.ssl.ServerHello$T13ServerHelloConsumer.consume(ServerHello.java:1277)
at sun.security.ssl.ServerHello$ServerHelloConsumer.onServerHello(ServerHello.java:966)
at sun.security.ssl.ServerHello$ServerHelloConsumer.consume(ServerHello.java:869)
at sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:377)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422)
at sun.security.ssl.TransportContext.dispatch(TransportContext.java:182)
at sun.security.ssl.SSLTransport.decode(SSLTransport.java:152)
at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1397)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1305)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440)
at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:317)
at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188)
at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:97)
at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:333)
… 11 more
Caused by: java.security.InvalidKeyException: Invalid key
at com.rsa.cryptoj.o.bl.a(Unknown Source)
at com.rsa.cryptoj.o.bl.engineInit(Unknown Source)
at javax.crypto.Mac.init(Mac.java:413)
at sun.security.ssl.HKDF.extract(HKDF.java:91)
at sun.security.ssl.HKDF.extract(HKDF.java:119)
at sun.security.ssl.ECDHKeyExchange$ECDHEKAKeyDerivation.t13DeriveKey(ECDHKeyExchange.java:469)
… 27 more"

This is an SSL error, completely different than the first error you reported. Turn off SSL and that will prolly go away. I assume the older Java 8 JRE doesn’t have the same SSL bits that the newer driver expects.

Interesting – how does one turn off SSL?

Have you tried Googling it? This is a general purpose question about the MySQL JDBC driver.

I did, but none of the results I get make it real clear where or how that’s done. I saw something that said the connection URL should look something like:
jdbc:mysql://localhost:3306/Peoples?autoReconnect=true&useSSL=false

And other that says to set useSSL=false&requireSSL=false

But set those where? In MySQL?

In your JDBC URL. You should be able to add custom items to the connection string under advanced settings.

Ah, okay – I’ve never used that before. I’m looking for an example of what the exact syntax should be. Something like: “jdbc:mysql://localhost:3306/database_name?useSSL=false” ? The Admin is rejecting even that basic syntax as the connection string…

Again, just for posterity – today I’m trying a different tack. I figure, why not just use the same Java that the client’s CF Server is using. So I’ve removed the rule in my server.json:
"JVM":{"javaVersion":"openjdk8"}
and added a rule for a custom Java version (which I copied from the client’s server) by typing in Commandbox:
server set jvm.JavaHome="C:\Users\cmaso\Sites\MyLocalDevSite\materials\jdk1.8.0_361"
(Note - I learned the hard way that I had to do it this way, and NOT by just pasting the rule into my server.json.)
I copied the jdk1.8.0_361 folder from the client’s server and put it in that “materials” folder. Now my CF11 server still starts up as expected. However, I’m still having the same issue I was yesterday with trying to connect to my local MySQL DB as a data source in CF Admin.
Just as a temporary test, I’m going to try connecting the client’s prod MySQL DB as a data source, and see if that works. If so, that’ll tell me that the issue is just with connecting to MySQL on my local machine – which is the most recent version of MySQL – and the solution might be just grabbing an older version of MySQL.