user11590977
user11590977

Reputation:

How to connect and access (like editing) with azure sql

I am bit new to azure so i m bit confused regarding this,

I have created a microsoft azure sql database

I want to manage it via android studio in java

I have got some videos reagrding connecting android =>sqlite=> ms sql server =>Azure SQL database

Is there any simpler or better way to achieve the same

Upvotes: 2

Views: 75

Answers (2)

Alberto Morillo
Alberto Morillo

Reputation: 15658

Below is a sample code to connect from Android Studio

import java.sql.*;

public class Test {

    public static final String url = "jdbc:sqlserver://***.database.windows.net:1433;database=***;user=***password=***;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;";
    public static final String name = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

    public static Connection conn = null;
    public static PreparedStatement pst = null;
    public static Statement stmt = null;
    public static ResultSet rs = null;

    public static void main(String[] args) {

        try {

            String SQL = "select * from dbo.Student";
            Class.forName(name);
            conn = DriverManager.getConnection(url);

            stmt = conn.createStatement();
            rs = stmt.executeQuery(SQL);

            while (rs.next()) {
                System.out.println(rs.getString("name"));
            }
            close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void close() {
        try {
            conn.close();
            stmt.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}

You can use Azure SQL Database REST API to manage all your databases. REST API documentation with examples can be found here.

Upvotes: 1

Shubham Kumar Gupta
Shubham Kumar Gupta

Reputation: 1147

You can try this :

This video from Microsoft Developer channel could help you get started:

https://youtu.be/kITLR2NgyY4

It talks about how to use the Azure Blockchain Development Kit for developing mobile apps.

Upvotes: 0

Related Questions