MySQL and Keycloak setup - mysql

Hello I am trying to add mysql database in my Keycloak server.
I've added module.xml and mysql-connector-java-5.1.42-bin.jar under /modules/system/layers/base/com/mysql/main.
When I am running the command to add mysql module,
./jboss-cli.sh, it errors out with
Exception in thread "CLI Terminal Connection (uninterruptable)"
java.lang.ArithmeticException: / by zero
And when i am trying to start Keycloak, I am also notified that there is a missing service.
service jboss.jdbc-driver.mysql (missing)
Please help!!

When I am running the command to add mysql module, ./jboss-cli.sh, it errors out with
Can you post your Command? You dont't have to do this with the cli. It's also possible to modify the config in a editor. At least for testing you should try this.
Keycloak docs have a pretty good part about database setup: https://www.keycloak.org/docs/latest/server_installation/index.html#_database
The basic steps are:
Locate and download a JDBC driver for your database
Package the driver JAR into a module and install this module into the server (module.xml)
Declare the JDBC driver in the configuration profile of the server (standalone.xml)
Modify the datasource configuration to use your database’s JDBC driver
Modify the datasource configuration to define the connection parameters to your database

There is an error in the Keycloak documentation. Driver should be in the
modules/system/layers/base/com/mysql/driver/main
folder.
The full valid instruction is here
https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-configuration
Also you can use docker images to experiment
https://github.com/v-ladynev/keycloak-nodejs-example#keycloak-docker-image

Related

Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql//10.0.1.86/mp_gws'

SO I am trying to connect to Mysql through JMeter and this error comes up everytime. I am using Mysql through VPN and while running the test plan I am already logged in into VPN. I have already added the jar to lib folder of JMeter and the path to the jar file to Test plan. Please Help!!!
Add the jar file with latest version and give proper path in jdbc connection configuration. as jdbc:mysql://192.168.0.00:3306/db_name. Using this connection configuration fixes the problem for me.
Your connection string is malformed, according to Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J it should be something like:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
So you need to amend your JDBC URL to:
jdbc:mysql://10.0.1.86:3306/mp_gws
Also make sure you have Connector/J jar somewhere in JMeter Classpath. Make sure you restart JMeter to pick the .jar up.
Check out MySQL Database and JMeter - How to Test Your Connection article for more detailed steps if required.

Cannot connect to MySQL docker instance via DataGrip application

I have managed to successfully connect to a docker instance running MySQL via the mysql command line utility. However, I am struggling to do so via DataGrip application from JetBrains.
My mysql cli command is as follows:
mysql -h127.0.0.1 --port=8181 -uroot
The connection string that is generated in DataGrip is:
jdbc:mysql://127.0.0.1:8181
The error I am getting from DataGrip interface is:
[08001] Could not create connection to database server. Attempted reconnect 3 times. Giving up.
Is there anything that need to change in DataGrip that I am missing. I have read that the connection has to also be done via TCP. Not sure how to check that DataGrip is doing that.
Update: I eventually found the problem was the docker container I was using. It seems DataGrip is not able to connect to version 8.0.1 (mysql:8.0.1) mysql docker container. I tested using version 5.7 of the container and could successfully connect.
I was having an issue connecting MySQL 8.0.3 using DataGrip. You need to download the JDBC driver from Oracle website. Select Developer Releases (Since this is an unstable version). The 8.0.8 version worked for me. Download and save in a project folder or something similar on your computer. You will gonna need it later.
Go to DataGrip: File > DataSources. Click on the + and select Driver:
Screenshot of the Step above
On the section Driver Files > Additional files click on the + and select the jar file you just downloaded
After that on the Class dropdown select com.mysql.jdbc.Driver
Mark Dialect as MySQL
On the section URL templates, put the Name as default and Template as jdbc:mysql://{host::localhost}?[:{port::3306}][/{database}?][\?<&,user={user},password={password},{:identifier}={:identifier}>]
Click on apply
Done!
Screenshot of MySQL 8.0.3 running on Datagrip
Add a new datasource using the new driver.
If you find the following error:
[01S00] The server time zone value 'PDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support
You can do a temporary fix going to the Advanced tab and setting the serverTimezone variable for UTC as an example.
There are no *.jar-files anymore. Only *.deb-packages for my OS on the Oracle site https://dev.mysql.com/downloads/connector/j/5.1.html
So I selected driver Amazon Aurora MySQL for my MySQL 8.0.3 in docker.
It works!

Unable to connect to snappydata store with spark-shell command

SnappyData v0.5
My goal is to start a "spark-shell" from my SnappyData install's /bin directory and issue Scala commands against existing tables in my SnappyData store.
I am on the same host as my SnappyData store, locator, and lead (and yes, they are all running).
To do this, I am running this command as per the documentation here:
Connecting to a Cluster with spark-shell
~/snappydata/bin$ spark-shell --master local[*] --conf snappydata.store.locators=10.0.18.66:1527 --conf spark.ui.port=4041
I get this error trying to create a spark-shell to my store:
[TRACE 2016/08/12 15:21:55.183 UTC GFXD:error:FabricServiceAPI
tid=0x1] XJ040 error occurred while starting server :
java.sql.SQLException(XJ040): Failed to start datab
ase 'snappydata', see the cause for details.
java.sql.SQLException(XJ040): Failed to start database 'snappydata',
see the cause for details.
at com.pivotal.gemfirexd.internal.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:124)
at com.pivotal.gemfirexd.internal.impl.jdbc.Util.newEmbedSQLException(Util.java:110)
at com.pivotal.gemfirexd.internal.impl.jdbc.Util.newEmbedSQLException(Util.java:136)
at com.pivotal.gemfirexd.internal.impl.jdbc.Util.generateCsSQLException(Util.java:245)
at com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection.bootDatabase(EmbedConnection.java:3380)
at com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection.(EmbedConnection.java:450)
at com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection30.(EmbedConnection30.java:94)
at com.pivotal.gemfirexd.internal.impl.jdbc.EmbedConnection40.(EmbedConnection40.java:75)
at com.pivotal.gemfirexd.internal.jdbc.Driver40.getNewEmbedConnection(Driver40.java:95)
at com.pivotal.gemfirexd.internal.jdbc.InternalDriver.connect(InternalDriver.java:351)
at com.pivotal.gemfirexd.internal.jdbc.InternalDriver.connect(InternalDriver.java:219)
at com.pivotal.gemfirexd.internal.jdbc.InternalDriver.connect(InternalDriver.java:195)
at com.pivotal.gemfirexd.internal.jdbc.AutoloadedDriver.connect(AutoloadedDriver.java:141)
at com.pivotal.gemfirexd.internal.engine.fabricservice.FabricServiceImpl.startImpl(FabricServiceImpl.java:290)
at com.pivotal.gemfirexd.internal.engine.fabricservice.FabricServerImpl.start(FabricServerImpl.java:60)
at io.snappydata.impl.ServerImpl.start(ServerImpl.scala:32)
Caused by: com.gemstone.gemfire.GemFireConfigException: Unable to
contact a Locator service (timeout=5000ms). Operation either timed out
or Locator does not exist. Configured list of
locators is "[dev-snappydata-1(null):1527]".
at com.gemstone.gemfire.distributed.internal.membership.jgroup.GFJGBasicAdapter.getGemFireConfigException(GFJGBasicAdapter.java:533)
at com.gemstone.org.jgroups.protocols.TCPGOSSIP.sendGetMembersRequest(TCPGOSSIP.java:212)
at com.gemstone.org.jgroups.protocols.PingSender.run(PingSender.java:82)
at java.lang.Thread.run(Thread.java:745)
hmm! I assume you are trying the Spark-shell from your desktop and connecting to the cluster in AWS?
Not sure this is going to work because the local JVM launched by spark-shell will attempt to connect to the p2p cluster in Snappydata which is not likely to work.
Snappy-shell on the other hand merely uses the JDBC client to connect (and, hence will work).
And, you cannot use the locator client port (1527), anyway. See here
Can you try with snappydata.store.locators=10.0.18.66:10334 NOT 1527 as the port ? Unlikely this will work but worth a try.
Maybe there is a way to open up all ports and access to these nodes on AWS. Not recommended for production, though.
I am curious for other responses from the engg team.
Until then, you may have to start the spark-shell from within the network (AWS node).

Using SSL with command-line Flywaydb ( flyway ) to deploy DB changes

I'm working on a proof of concept to deploy using flyway's command-line tool from a centralized server to deploy to multiple database platforms. (MySQL, Postgres, and SQL Server)
I'm able to deploy successfully without SSL, however it is using unencrypted host information such as logins/passwords/ports to the destination Database Server. My concern is there's a chance the un-encrypted traffic could be seen.
Does anyone have experience with the flyway command line tool using SSL to deploy to:
MySQL
SQL Server
I did not see any information in the documentation unless I missed it.
Thanks for any help and suggestions!
In the flyway examples in flyway.conf it shows how to add additional values to the jdbc url for example
# MySQL : jdbc:mysql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
# PostgreSQL : jdbc:postgresql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
# Redshift : jdbc:postgresql://<host>:<port>/<database>?<key1>=<value1>&<key2>=<value2>...
So for Redshift/Postgres for example you can include the ssl=true flag
flyway.url=jdbc:postgresql://yourserver:5439/dbname?ssl=true
You need to add the public key that the DB server key was signed with to your hosts trust store (for Redshift see http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-ssl-support.html for details on that), e.g
${JAVA_HOME}/bin/keytool -keystore ${JAVA_HOME}/lib/security/cacerts -import -alias <alias> -file <certificate_filename>
I then had to hack the flyway startup script /flyway to include the truststore and password in the JAVA_ARGS (it probably should have these as variables) e.g
JAVA_ARGS="-Djava.security.egd=file:/dev/../dev/urandom -Djavax.net.ssl.trustStore=/etc/pki/java/cacerts -Djavax.net.ssl.trustStorePassword=changeit"
For MySQL I used the following URL to connect using SSL.
jdbc:mysql://hostname:3306/wpastudy?useSSL=true
Note the useSSL=true parameter.

Why am I unable to connect Sql server 2008 R2 from tibco BW?

When I'm trying to connect to sql server from tibco JDBC connection getting the following errors.
For com.microsoft.sqlserver.jdbc.SQLServerDriver
BW-JDBC-100034 "Configuration Test Failed. Exception [com.microsoft.sqlserver.jdbc.SQLServerException] occurred. com.microsoft.sqlserver.jdbc.SQLServerException: Software caused connection abort: recv failed"
and for tibcosoftwareinc.jdbc.sqlserver.SQLServerDriver
BW-JDBC-100033 "Configuration Test Failed. Failed to find or load the JDBC driver: tibcosoftwareinc.jdbc.sqlserver.SQLServerDriver"
I've placed the jar files in C:\tibco\tpcl\5.7\lib folder and also tried by placing the jar files in C:\tibco\tpcl\5.7\jdbc folder.
Can any please let me know how to solve this problem?
you should put the jar files in tibco bw/lib folder.
For me its C:\tibco\bw\5.10\lib
Additionally if you want to connect ms sql server using windows authentication then you also have to keep windows/system32 folder or add to class path.
Your JDBC drivers should be placed in:
C:\tibco\tpcl\5.7\jdbc
You must create the jdbc folder if it doesn't exist.
I had the same problem and Its resolved now.
First - Check If you are able to connect to a different Sql server using the JDBC connection in Tibco designer. If yes - there is an issue with the Sql server in your machine.
You should upgrade to Sql Server 2008 Service Pack 2. I did, restarted my Sql server and was able to connect. Download it from here. Also you need to make sure you have the jdbc folder in your C:\tibco\tpcl\5.7\ and you have the corresponding class path tibco.env.STD_CP_EXT in the designer.tra.
Just FYI, a relevant fix is in in SP2 patch:-
http://support.microsoft.com/kb/2653857
FIX: You cannot connect to SQL Server by using JDBC Driver for SQL Server after you upgrade to JRE 6 update 29 or a later version