question

DENZARLI-8506 avatar image
0 Votes"
DENZARLI-8506 asked DENZARLI-8506 commented

I can't connect to azure sql server with my android app.

I can't connect to azure sql server with my android app. I'm using jtds jar for connecting to sql server but I can't. Android studio giving this error: "E/Error is: Login failed for user 'sharkman'." How can I connect to my sql server?

azure-sql-database
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered AlbertoMorillo commented

Please make sure are trying to get connected correctly. Try something like below:

 try {
    
     String SQL = "select * from dbo.Student";
    
     Class.forName("net.sourceforge.jtds.jdbc.Driver");
     String url = String.format("jdbc:jtds:sqlserver://***.database.windows.net:1433/<your database name>;user=***;password=***;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;");
     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();
 }

I hope this YouTube video helps you go through all the steps.




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Still not working. Error on 7. line

0 Votes 0 ·

Check out the YouTube Video

0 Votes 0 ·
AlbertoMorillo avatar image
0 Votes"
AlbertoMorillo answered DENZARLI-8506 commented

Let me know if this article (example) works for you.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Not working. I can connect my other databases but I can't connect azure sql database.

0 Votes 0 ·