3

I have created a batch file to connect to HSQL database, here when we entered the password to connect to database it appears as a clear text

we cannot specify a non-empty password as an argument. You will be prompted for a password as part of the login process.but it appears that while password is being entered, it appears as clear text and as typed! I want to mask this password, it should appear as ***.

My batch file:

java -jar sqltool.jar --inlineRc=url=jdbc:hsqldb:hsql://localhost:8888/XX,user=DDD
java
  • 31
  • 3
  • 1
    When you say "DOS", do you mean a Windows command prompt (i.e. `cmd.exe`)? – zb226 Oct 22 '15 at 16:02
  • Yes, I have created batch file and executed on command propt – java Oct 22 '15 at 16:13
  • OK. Have look at [this question](http://stackoverflow.com/questions/664957/can-i-mask-an-input-text-in-a-bat-file) question, more specifically, [this answer](http://stackoverflow.com/a/20343074/1529709). – zb226 Oct 22 '15 at 16:17
  • Thanks for ur input, I have tried using the details given in the page but sqltool.jar have inbult functionality to prompt for the password when we not provide. Again, when this application is deployed on linux and from there i will point to my bat file to connect to database.. I think powershell will not execute from bash consol... Can u suggest some other way..Thanks in advance – java Oct 22 '15 at 16:20
  • @java wouldn't that be a problem with your sqltool.jar and not a batch file problem. That seems like a function of your java program. It is definitely not a batch file problem. – Squashman Oct 22 '15 at 16:30
  • @Squashman is right. Skimming though the [docs](http://hsqldb.org/doc/2.0/util-guide/sqltool-chapt.html), you could provide it in a `sqltool.rc` file, albeit in plain-text as well. – zb226 Oct 22 '15 at 16:32

1 Answers1

0

Java provides the Console class for basic terminal IO, including not displaying passwords the user inputs via readPassword():

Reads a password or passphrase from the console with echoing disabled

This is not secure in any way - the password is still entered as cleartext - but if your intent is simply to avoid the password being seen on the screen as it's entered, this is the correct mechanism.

dimo414
  • 47,227
  • 18
  • 148
  • 244