spring boot --spring.application.json parameters not being set - json

I have a spring boot application that currently has a "mysql" profile that sets the following properties:
spring.datasource.url =
spring.datasource.username =
spring.datasource.password =
in /resources/application-mysql.properties file.
This is working great. When I run the mysql profile it connects to the local mysql database. When I don't run the mysql profile it uses the default h2 database. Next I want to get rid of the application.my-sql.properties and pass those values in via the command line. From the documentation here I would expect something like the following to work. But strangely, it never gets these properties and runs the h2 database instead.
java -jar myapp-0.0.1-SNAPSHOT.jar --spring.application.json='{"spring": {"datasource": {"url":"jdbc:mysql://localhost:3306/db", "username":"user","password":"pw"}}}'

I can confirm that this does work. As Vaelyr pointed out in the comments, setting it as system argument worked:
-Dspring.application.json='{"spring":{"datasource":{"username":"yourusername","password":"yourpassword"}}}'

Related

DatabaseLibrary in RobotFramework

I'm using this libary...
https://franz-see.github.io/Robotframework-Database-Library/api/1.2.2/DatabaseLibrary.html
then in the .robot file I have this set-up:
TC check database
# DatabaseLibrary.Connect To Database dbapiModuleName=None dbName=SpecimenDatabase dbUsername=testenvans_admin dbPassword=wwSpecimen01 dbHost=specimen.domeinwinkel.nl dbPort=443 dbCharset=None dbConfigFile=db.cfg
Connect To Database Using Custom Params dbapiModuleName=None, db_connect_string=='SpecimenDatabase', user='Specimen_user', password='SpecimenPassword', host='s99.specimenhost.com', port=5432
but no matter what I do it keeps saying: no Module named None
what IS dbapiModuleName actually?
Connect to your MySQL database from a remote connection. My answer is: https://help.directadmin.com/item.php?id=308

In moqui, configuration to use mysql and loading with seed data

In moqui, I am trying to configure to use mysql, commented out derby and uncommented mysql in defaultconf, I copied the connector to framework lib, included the dependency in framework build.gradle, on running load, I get this error - java.lang.reflect.InvocationTargetExceptionjavax.management.InstanceAlreadyExistsException: bitronix.tm:type=JDBC,UniqueName=DEFAULT_transactional_DS,Id=0 -- thanks for any help
Can you post a snippet of code you have modified in MoquiDefaultConf.xml and build.graddle file.
A viable alternative to configure MySQL with Moqui is by doing related setting in configuration files (i.e. MoquiDevConf.xml for development instance, MoquiStagingConf.xml for staging instance and MoquiProductionConf.xml for production instance.). Follow the steps below to configure MySQL with Moqui.
Since, May be you are trying to do some development, you need to make changes in MoquiDevConf.xml file only.
Replace the <entity-facade> code in MoquiDevConf.xml with the following code.
<entity-facade crypt-pass="MoquiDefaultPassword:CHANGEME">
<datasource group-name="transactional" database-conf-name="mysql" schema-name="">
<inline-jdbc jdbc-uri="jdbc:mysql://127.0.0.1:3306/MoquiTransactional?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"
jdbc-username="MYSQL_USER_NAME" jdbc-password="MYSQL_PASSWORD" pool-minsize="2" pool-maxsize="50"/>
</datasource>
</entity-facade>
In the code above 'MoquiDEFAULT' is the name of database. Replace the MYSQL_USER_NAME and MYSQL_PASSWORD with your MySQL username and password.
Create a database in MySQL (as per the code above, create the database with name MoquiTransactional).
Add the jdbc driver for MySQL in the runtime/lib directory.
In MoquiInit.properties file, set MoquiDevConf.xml file path to "moqui.conf" property i.e. moqui.conf=conf/MoquiDevConf.xml
Now just simply build, load and run.
To answer your question for loading seed data,
you can simply the run the gradle command gradle load -Ptypes=seed, this only loads the seed type data.
Without more details my best guess is that you have another instance of Bitronix running on the machine, by the UniqueName almost certainly another instance of Moqui running. Make sure no other instance is running, killing background processes if there are any, before starting your new instance.

Hosting a keystonejs app with openshift

I keep getting a 503 but no errors in the log when trying to host my keystone.js app on openshift, has anyone successfully hosted a keystone app with them? Everything works fine on localhost.
I am using a fresh install of keystone.js with no blog or cloudinary.
Your providing very little information to give you a definitive answer. What options are you passing to keystone.init()? Are you using dotenv? If so, what are you setting there? Did you set any environment variables using rhc set-env?
I ask because a common (though not by far the only) culprit of 503 errors in Node.js applications on OpenShift is a port number overriding OpenShift's. Keystone looks at process.env.PORT before it looks at process.env.OPENSHIFT_INTERNAL_PORT. So, if you have PORT set on your .env or with rhc set-env it will take precedence over OPENSHIFT_INTERNAL_PORT.
I came across a similar question on the KeystoneJS Google Group. In that other case the developer had added a MONGODB cartridge to his app, but had not set the connection string for the cartridge in Keystone.
If this is your case as well you need to set the Keystone mongo option in Keystone.init() or using Keystone.set('mongo', 'connection_sring'). When you created the cartridge you got a url and some credentials. OpenShit passes these to your application in environment variables. You can build the mongo connection string as follows:
var connectionString = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" + process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "#" + process.env.OPENSHIFT_MONGODB_DB_HOST + '/' + process.env.OPENSHIFT_APP_NAME;
keystone.set('mongo', connectionString);
or
keystone.init({
...
mongo: connectionString,
...
});
Or you can use rhc set-env to set the MONGO environment variable as follows:
rhc set-env MONGO=http://{username}:{password}#{connection url}/{dbname} -a your_app_name
The connection url above is the one you got from OpenShift when you created the cartridge. If looks like a standard MONGODB url (e.g. mongodb://127.6.85.129:27017/).
These are just my best guesses, given that your question is a bit thin on details. You may want to post some more specifics so we can more accurately assess your problem.

WSO2 App Store throws error when attempting to save a users Application against mysql

API Store is throwing errors when I try to create or edit an application
java.sql.SQLException: Can't call commit when autocommit=true
I've added the setting of
init-command='set autocommit=0'
to the my.cnf file
I've also added the flag:
?relaxAutoCommit=true
to the connection string but to no avail. I continue to get this error.
I am using the same mysql database for both the WSO2_CARBON_DB and teh WSO2AM_DB plus I have a single publisher node and two separate store nodes all pointing to the same mysql datasource.
I notice the application edit is saved (or the new application is created) but the exception is still thrown in the console and an error message appears in the user interface (as per the error at the top of this question).
Is there some other setting, within the WSO2 conf files that I have to tweak in order to get this to work properly?
Add both autoReconnect and relaxAutoCommit flags to the jdbc url of your defined "WSO2AM_DB" datasource in master-datasources.xml file. This will resolve your issue.
<configuration>
<url>jdbc:mysql://localhost:3306/AM_DB?autoReconnect=true&relaxAutoCommit=true</url>
<username>xxxx</username>
<;password>xxxxx</password>
EDIT: I updated the url to reflect the correct syntax for escaping the ampersand.
just for the sake of completeness, the JDBC URL shoud be
jdbc:mysql://localhost:3306/WSO2CARBON_DB?autoReconnect=true&relaxAutoCommit=true

Unable to run Play Framework 1.2.4 application using ClearDB on heroku

here is the ClearDB url given by heroku, which I have placed in my application.conf:
mysql://ce321a40b79906:ad8a252e#us-cdbr-east.cleardb.com/heroku_171088b609e621d?reconnect=true
This doesn't work ! The log show following exception:
←[36m2012-05-03T15:45:52+00:00 app[web.1]:←[0m Caused by: com.mysql.jdbc.excepti
ons.jdbc4.MySQLSyntaxErrorException: Table 'heroku_171088b609e621d.user' doesn't exist
Where as when I use Postgres using following configuration, it works perfectly fine:
db=postgres://xfqolvejdz:nRofWB6Lg1V9JDadmjfW#ec2-50-19-226-184.compute-1.amazonaws.com/xfqolvejdz
jpa.dialect=org.hibernate.dialect.PostgreSQLDialect
jpa.ddl=update
What am I missing here ?
The best way is to use the environment variables instead of copy and pasting URLs. For Postgres the lines in the conf/application.conf are:
%prod.db=${DATABASE_URL}
%prod.jpa.dialect=org.hibernate.dialect.PostgreSQLDialect
%prod.jpa.ddl=update
For ClearDB the following should work:
%prod.db=${CLEARDB_DATABASE_URL}
%prod.jpa.dialect=org.hibernate.dialect.MySQLDialect
%prod.jpa.ddl=update