Connect to Azure DB via java: Network error IOException: SSL handshake aborted

Lander De Waele 0 Reputation points
2023-04-25T20:19:05.4566667+00:00

While trying to connect to an Azure DB via java in Android Studio I got the following error message: java.sql.SQLException: Network error IOException: SSL handshake aborted: ssl=0x7455299a00: I/O error during system call, Broken pipe I use jtds-1.3.1.jar and my code for connection looks like this:

Thread thread = new Thread(() -> {
                    try {
                        // Load the jTDS driver
                        Class.forName("net.sourceforge.jtds.jdbc.Driver");
                        // Establish the database connection
                        String connectionUrl = "jdbc:jtds:sqlserver://bluetooth.database.windows.net:1433;DatabaseName=BluetoothDB;user=beheerder@bluetooth;password={password};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;ssl=require;";
                        Connection connection = DriverManager.getConnection(connectionUrl);
                        // Create an SQL query to insert data into the database
                        String sql = "INSERT INTO Results (Result, Date) VALUES (?, ?)";
                        PreparedStatement statement = connection.prepareStatement(sql);
                        statement.setString(1, readValue);
                        statement.setString(2, dateNow);
                        // Execute the SQL query
                        statement.executeUpdate();
                        // Close the statement and connection
                        statement.close();
                        connection.close();
                    } catch (ClassNotFoundException | SQLException e) {
                        e.printStackTrace();
                        // Handle any exceptions that may occur during the database operation
                    }
                });

First I got TLS version to low so I added "ssl=required"

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-04-25T22:16:36.6666667+00:00

    Could you please try the multiple solutions provided on this StackOverflow forum thread?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.