Android get connection to sql server - android

I need to connect to local sql server, but when run code below,
con = DriverManager.getConnection("jdbc:jtds:sqlserver://10.0.3.2:8080/app", "test", "1234");
the logcat display warning message:
06-10 01:24:22.112 2676-2676/com.example.androidapp.helloandroid W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
I dont know what does the warning message means?? I have tried to googled and they recommend use localhost/127.0.0.1/10.0.2.2/10.0.3.2/(local ip address) or remove port number, but it isn't working...

you can not use localHost there should be client server communication. Between a device and server.
So use an ip address remove localHost from url and if you are able to ping that ip from another machine then only we can access it from your android device.

Related

Getting "You don't have permission to access that port" error in Django

I want to run my Django API to my IP address which is 192.168.1.5:81 with port number but I am getting that You don't have permission to access that port.
I have done port forwarding in my router.
I am doing this because I want to get data in my Android application using retrofit.
i checked my available ports on my IP address then i ran code with the open port and solved this.
also i added my IP address inside ALLOWED_HOSTs in settings.py file

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.

connection refused error while accessing adapter from app

I have an adapter on my worklight server which is publicly hosted and my adapter is using some external ip 164.100.XXX.XX:9090 , now when i am trying to access that adapter from my mobile phone i am getting following error in logs
11-19 03:47:01.499: E/NONE(2363): Procedure invocation error. Runtime:
Http request failed: org.apache.http.conn.HttpHostConnectException:
Connect to 164.100.XXX.XX:9090 [/164.100.XXX.XX] failed: Connection
refused: connect
what do i need to configure on worklight server to unlock ip and port
You do not configure anything in the MobileFirst Server for this.
If an IP address is not available, that means it is not really the correct IP address to use... you need to double-check the IP address and its port. You need to verify that's really an external, public, IP address. 164.0.0... does not seem external at all.

android mobile connect to sql server

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.

SmartFoxServer unable to connect to server

I am working in android chat application.
I used SmartFox server. I am using 10.0.2.2 as server IP address and 9933 as Port.
Whenever i run this application using emulator then works fine but when i run this application in my real device then connection does not performed correctly. I think this is unable to find out IP 10.0.2.2.
I changed this IP address to 192.168.1.9 which is IP address of my system in LAN on which SmartFox server is installed.
Please suggest me what mistake i have done.
Thank you in advance.
I resolved my problem myself. I created one entry in confi/server.xml file of server.
like this:-
<serverSettings>
<socketAddresses>
<socket address="192.168.1.9" port="22" type="TCP"/>
<socket address="192.168.1.9" port="22" type="UDP"/>
</serverSettings>
</socketAddresses>
or you may add this entry using admin module of Smartfox server. This task can be done using Server configuration part.

Categories

Resources