Liquibase can not read jdbc postegresql connection string with username and password - liquibase

The documentation on the Liquibase website says that I can use the full connection string in the --url parameter such as
jdbc:postgresql://host:port/database?user=user&password=secret
yet when I run any command such as
liquibase history --url='jdbc:postgresql://host:port/database?user=user&password=secret'
I get the following error:
Unexpected error running Liquibase: Connection could not be created to jdbc:postgresql://host:5432/database?user=user with driver org.postgresql.Driver. The server requested password-based authentication, but no password was provided.
For more information, please use the --log-level flag
'password' is not recognized as an internal or external command,
operable program or batch file.
It looks like the & makes Liquibase split the connection string into two commands. It works if I provide the --user and --password parameters separately : liquibase history --url='jdbc:postgresql://host:port/database --user='user' --password='secret'.
Am I doing something wrong? I'm running this in PowerShell.

Your connection string should look something like:
postgresql://[user[:password]#][netloc][:port][/dbname][?param1=value1&...]
So it should be:
liquibase history --url='jdbc:postgresql://user:password#host:port/database'
Thanks to https://stackoverflow.com/a/20722229/2864019

Related

SnowSQL login issue

I am trying to login into snowSQL for the first time and i am getting this below error. I want to know what is wrong with the below statement.
snowsql -a LTA43954.US-west-oregon.aws -u INDUMATHI
and the error is
250001 (n/a): Could not connect to Snowflake backend after 0 attempt(s).Aborting
If the error message is unclear, enable logging using -o log_level=DEBUG and see the log to find out the cause. Contact support for further help.
Please help me out
Is your snowflake instance up?
Also check your region, if you are using correct one. I checked on oregon, looks like its us-west-2. Please try using that and see if it works.
You can also try to put all this in your snowflake config file and just type snowsql (without any parameters) and it should log you in.
The default location for config file is your homedirectory/.snowsql/config
On windows - c:\users<username>.snowsql\config
accountname = LTA43954
region = US-west-oregon.aws
username = INDUMATHI
password =
Password you can provide in config file or you will be prompted for it.
I tested connectivity using same and it gave me password prompt, so it means its working. Please refer below for the test I did.
It appears your snowflake instance was not up or had some issue/outage, as now its connecting fine.
The account name has an incorrect region id appended to it. It should be as follows:
snowsql -a LTA43954.us-west-2 -u INDUMATHI
Try this and verify

Supply password to HSQLDB SqlTool in a script

I am running an HSQLDB instance in server mode as a systemd service. To shut it down, I issue the following command:
java -cp $CLASSPATH:/usr/share/java/hsqldbutil.jar:/usr/share/java/hsqldb.jar "org.hsqldb.cmdline.SqlTool" --inlineRc=url=jdbc:hsqldb:hsql://localhost/$DB_NAME,user=SA,password=`cat ~/SA.pwd` --sql="SHUTDOWN;"
As one can see in the command, I connect as user SA with a password read from a file (which only that particular user can read), and specify both in the JDBC URL.
This works as long as SA has an empty password and I just supply password= in the command.
However, if SA has a real password and I supply it here, this fails with the error message:
'password' element must have empty value. For non-empty password, give no password element and you will be prompted for the value.
Is there any way to supply the password in a non-interactive way?
It works if you use a sqltool.rc file instead of --inline-rc. Place a file with the following contents in the home folder of the account which will be issuing the stop command:
urlid my-server
url jdbc:hsqldb:hsql://localhost/db_name
username SA
password CorrectHorseBatteryStaple
Then modify the command line as follows:
java -cp $CLASSPATH:/usr/share/java/hsqldbutil.jar:/usr/share/java/hsqldb.jar "org.hsqldb.cmdline.SqlTool" --sql="SHUTDOWN;" my-server
Where:
my-server is an arbitrary identifier that you define in sqltool.rc and quote in the command line invocation of SqlTool
db_name is the database name assigned at startup
CorrectHorseBatteryStaple is the SA password (as currently stored in ~/SA.pwd).
Change these as appropriate for your system. As sqltool.rc contains credentials, be sure to lock down its permissions as you would for ~/SA.pwd.

Connect to sqlplus in shell script and run sql script with separate password

I am writing a shell script in Jenkins that logs into a database and runs an sql file. All of the commands are logged to the console, so if I use the simple login method for sqlplus (sqlplus -s $USERNAME/$PASSWORD#connectionstring), the password gets logged, which isn't ideal.
This works:
sqlplus -S ${USERNAME}/${PASSWORD}#connectionstring #sql_update.sql
but the logging on Jenkins shows the command once the values have been substituted:
+ sqlplus user123/pass123#connectionstring #sql_update.sql
To avoid having the password logged, I am trying to use the sqlplus login method where you just provide the username and then get asked to input the password.
I have tried the following, but I am getting ORA-01-17: invalid username/password; logon denied
sqlplus -s ${USERNAME}#\"connectionstring\" <<EOF
${PASSWORD}
sql_update.sql
exit
EOF
Is there something obviously wrong with this?
It's worth noting that simply disabling the console logging isn't an option, as we need it for other things in the script.
Also, the difference between this question and Connect to sqlplus in a shell script and run SQL scripts is that I am asking about providing the password separately.
EDIT I managed to partially resolve the issue thanks to Echo off in Jenkins Console Output. My script now contains set +xbefore the commands are run, which hides the commands. However, I'd still like to know what was wrong with the above, so am leaving this question open for now.

Error in Connection Testing in Mule Database connector

I am trying to connect mysql database with mulesoft database connector, but it is giving error while I do test Connection. I am not able to figure out what is wrong I am doing. Could you please put me in right direction?
Please ask for more information you need from me.
The problem you are facing is not because of Mule component.There may be several other reasons at MySQL side.
As you can see that your credentials are processed by MySQL however denied.This suggests that the problem may not be directly
related with credentials because if credentials were wrong the error would have been different then denied.
When credentials are denied, the problem is mostly related with:
Permission issue - Solution >> Grant permission to use "db_name" from "Localhost"
Your connection string looks fine but sometimes string encoding result this error
Some installed components are interfering with MySql -> Check the components installation
Also
LOCALHOST and "machine name" aren't the same to MySQL.
I'd check from the command line that you can connect to localhost:
mysql --user=<user_name> --password db_name
Enter password: your_password
If it fails, connect and run this with the appropriate permissions:
create user db_name#localhost identified by 'db_name';
grant select on <user_name>.* to db_name#localhost;
Never mind :) I found the solution although did not find what the problem was only suspecting that the root was not having any schema privileges ( as shown by MySQL Workbench GUI).
Earlier I was using command line with which I am not well versed; after struggling a little I downloaded MySQL workbench and added one more user with all administrative and schema privileges and used that to connect with Database connector and God Damn!! it's working.

how to connect to a file based HSQLDB database with sqltool?

I have tried to follow the instructions in chapter 1 of the HSQLDB doc and started my server like:
java -cp hsqldb-2.2.5/hsqldb/lib/hsqldb.jar org.hsqldb.Server -database.0 file:#pathtodb# -dbname.0 xdb
and I have reason to believe that worked cause it said (among other things):
Database [index=0, id=0, db=file:#pathtodb#, alias=xdb] opened sucessfully in 2463 ms.
However at the next step I try to connect using SqlTool and based on chapter 8 of the documentation I came up with this command to connect:
java -jar hsqldb-2.2.5/hsqldb/lib/sqltool.jar localhost-sa
Which gives the following error:
Failed to get a connection to 'jdbc:hsqldb:hsql://localhost' as user "SA".
Cause: General error: database alias does not exist
while the server says:
[Server#60072ffb]: [Thread[HSQLDB Connection #4ceafb71,5,HSQLDB Connections #60072ffb]]: database alias= does not exist
I am at a loss. Should I specify alias when connecting somehow? What alias would my database have then? The server did not say anything about that...
(also, yes I have copied the sqltool.rc file to my home folder.
Your server has -dbname.0 xdb as the database alias. Therefore the connection URL should include xdb. For example jdbc:hsqldb:hsql://localhost/xdb
The server can serve several databases with different aliases. The URL without alias corresponds to a server command line that does not include the alias setting.
java -jar /hsqldb-2.3.2/hsqldb/lib/sqltool.jar --inlineRc=url=jdbc:hsqldb:localhost:3333/runtime,user=sa
Enter password for sa: as2dbadmin
SqlTool v. 5337.
JDBC Connection established to a HSQL Database Engine v. 2.3.2 database
This error has been hunting me for the last 5 hours.
Together with this stupid error: HSQL Driver not working?
If you want to run your hsqldb on your servlet with Apache Tomcat it is necessary that you CLOSE the runManagerSwing.bat. I know it sounds trivial but even if you create the desired database and you run Eclipse J22 Servlet with Tomcat afterwards, you will get a bunch of errors. So runManagerSwing.bat must be closed.
See my sqltool answer over on the question "How to see all the tables in an HSQLDB database". The critical piece is setting up your sqltool.rc correctly and putting it in the right location.
You can also use the following statement for getting a connection from a files based store. this can be used if you are running the application from Windows.
connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", "");