A simple Spring Boot command line application to test JDBC connection to SQL Server database.
Download the JAR from release page or alternatively checkout the code from this repository and run:
mvn clean package
Execute the JAR file. Example below:
java -jar target/ms-sqlserver-jdbc-1.0.jar "jdbc:sqlserver://mydatabase.db.windows.net:1433;database=My_Example_DB;[email protected];password=secret123;encrypt=true;trustServerCertificate=true;loginTimeout=90;authentication=ActiveDirectoryPassword"
Security Tip: A good practise is to read the JDBC string into a variable using the
read
command in Linux to prevent DB credentials in JDBC string to be logged in bash history.
To test the JDBC connection, the app will attempt to connect to SQL Server and execute a single SQL query: SELECT SUSER_SNAME()
and close connection.
(The MIT License)
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.