Android e AZURE DATABASE

  • Respostas:0
  • AbertoNão stickySem resposta
  • Posts no fórum: 1

22/09/2018, 02:20:12 via Web

Pessoal tudo bem ?

Estou tentando fazer uma conexão no banco de dados AZURE mas esta ocorrendo o seguintes erro:

Code

public void ConnectTest (View view)
{
// Connect to database
String hostName = "---";
String dbName = "---";
String user = "---";
String password = "---";
String url = String.format("jdbc:sqlserver://%s:1433;database=%s;user=%s;password=%s;encrypt=true;hostNameInCertificate=*.database.windows.net;loginTimeout=30;", hostName, dbName, user, password);
Connection connection = null;

    try {
        connection = DriverManager.getConnection(url);
        System.out.println("Successful connection - Schema: ");

        System.out.println("Query data example:");
        System.out.println("=========================================");

        // Create and execute a SELECT SQL statement.
        String selectSql = "SELECT TOP 20 * From Alimentos ";

        try (Statement statement = connection.createStatement();
             ResultSet resultSet = statement.executeQuery(selectSql)) {

            // Print results from select statement
            System.out.println("Top 20 Alimentos:");
            while (resultSet.next())
            {
                System.out.println(resultSet.getString(1) + " "
                        + resultSet.getString(2));
            }
            connection.close();
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

ERRO : java.sql.SQLException: No suitable driver

Seja o primeiro a responder

Artigos recomendados