android mobile connect to sql server - android

I'm able to connect to local SQL server database by using Genymotion emulator. But when generate to APK and run on mobile, it doesn't connect to database. I notice the logcat shows "Connect failed: No route to host". I have turn on my wifi and the signal is very strong.
Below are methods that I have tried but still cannot solve it.
1) Turn ON/OFF wifi when run the app.
2) Set allow remote connection in SQL server.
3) Same network (Local IP= 192.168.0.110 Mobile IP: 192.168.0.114)
4) Using different port (80/1443)
My code:
con = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.110/app", "test", "1234");
or
con = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.110:1443/app", "test", "1234");

It is highly recommended not to connect to database servers from android directly. You need to have web server in between the android client and database server. Pass all your requests to the web server and make the web server in turn connect to the database.
Check this answer https://stackoverflow.com/a/12233178/3894784. It is for mysql database and almost similar to sqlserver with little changes in connection proerties.

Related

sql server connection in android studio

android studio, how connect to sql server withpout a server ip sample http:\myhomepage:1433
i dont waht to connect use an ip sample:
111.111.1.111:1433
To connect to your localhost server, you should be connected to the same network (Phone and the Computer with the server), just open cmd and type ipconfig and get the ip address for the server. in your android connection string enter http://ipaddress/projectfolder
You can only connect using the domain name http://example.com for a hosted live website since mobile devices won't recognize your localhost

how to get android emulator to connect to a specific port on our server

I am using Xamarin Forms to build an Android app. The data that the app will consume is stored on our server in a SQL database on our local network. I am using a C# Web API service (served by IIS) to connect the app to the server. All traffic will be inside our local network.
Currently the Web API is being served by IP address on port 90 - this was the only way I could get the emulator to be able to connect to the server, as no luck accessing it by name. I can fire up a browser on my development machine and load up http://10.1.1.15:90/api/Controller and I get back the data I was expecting.
I have also done a networkaccess check for access to 10.1.1.15 on port 90 using Powershell from my machine, which comes back Fine.
I use James Montemagno's Connectivity package to check for network access in the app - this returns true if I check for the IP address. It returns true if I check for the IP address on port 80. However it returns false if I check for the IP address on port 90. How can I get this to access the server on port 90? (BTW it will also need to access other services on port 91 and 92).
The android device was set up by default with a proxy. I toild it not to use the proxy and then it worked

JDBC can't connect to azure server for some WiFis: All IPs permitted

I want to connect to my Azure DB from Android. From Android side im using JDBC:
Connection con = ConnectionJDBC.connectionClass();
String query = "SELECT * FROM mytable";
Statement stmt = con.createStatement();
stmt.executeUpdate(query);
From azure side, my server is normally up and running and the firewall settings allow IPs 0.0.0.0 to 255.255.255.255. Everything else is unchanged.
That also works for most WiFi networks over which I made the request. However, it doesn't work for my university's WiFi (specifically ETH Zurich), con will just be null. Does someone know what the problem could be? I think it lies in the configuration of the Azure Server but I don't know what else I could change.
Please see JDBC vs Web Service for Android, as suggested by Morrison Chang: JDBC should not be used and is sometimes blocked. Instead create a mobile app service in Azure (they will change the name to web app service), and connect to that server, as suggested here: https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-android-get-started

Android app failed to connect to local server over WIFI

I'm developing an Android app that must connect to the server to retrieve some data. I've 2 devices connected on my local WIFI via a router: My development laptop (as server) and my development android phone (as client). The laptop has as IP address 192.168.41.50 and my Apache HTTP server is running on port 81.
My problem is the following:
If I run my android application to retrieve data into the server, it doesn't work, it's giving me a timeout exception:
D/OkHttp: <-- HTTP FAILED: java.net.SocketTimeoutException: failed to connect to /192.168.43.50 (port 81) after 120000ms
But the same address is working on the laptop's browser
How can I solve this problem.
Have a look at the firewall.
Switch it off for a test.
Your problem solution is simple ->
You have to allow external devices to connect your server.
If you are using Wamp Server then look at this post for your answer ->
How to enable local network users to access my WAMP sites?
If you are using Xampp Server then look at this post for your answer ->
Accessing localhost (xampp) from another computer over LAN network - how to?
Hope this solve your problem.

Accessing node.js server on my local system using android app

I have a node.js server running on my local system which interacts with postgresql in the same system to fetch and save data. I want to access node.js server from my android app to save and fetch data from postresql. The problem is my app is not able to connect to localhost. As localhost for my phone is different from my local system and if I am providing my system's IP address then also its refusing the connection.
I made server listen to hostname '0.0.0.0'. Initially I was not providing any hostname as argument in server.listen i.e it was like
server.listen('portnumber') which I changed to
server.listen('portnumber', '0.0.0.0');
if you are using android emulator and trying to access the the host machine's
local host use IP address : 10.0.2.2
for genymotion use IP address: 10.0.2.3
this should allow you to access the host machine's local host, but you will have to change this IP address to local IP address when running app on a device and connected to same network, to access from other network you need to open port(port forwarding I guess) in your router and talk ask your ISP to do the same.
here's a link to similar question : here

Categories

Resources