1

I've started developing an android application which connects to SQLServer DB, I've successfully connected to the DB with this connection string :

ConnURL = "jdbc:jtds:sqlserver://" + _IP+ ":" + _Port + ";" + "databaseName=" + _DB + ";useNTLMv2=true;integratedSecurity=true";

But it works only if i try it on a device which is connected to the same network in which the server is connected because the IP i put in the connection string is 192.168.1.7. What should i do to make it work if I try it in another network ? I've tried replacing that IP address with the IP address which i got from What Is My IP but it wont connect.

1 Answer 1

2

THat's because you're behind a NAT and that address isn't reachable to the outside world. You need to move to a server with a real IP address, or poke a hole in the NAT and allow address rerouting.

But that's ok, because you should NEVER directly connect to a db like this anyway- you not only have to allow your db server to be reached from a public internet, but you have to put your login info in your public app. Totally insecure. You should have a webservice between you and the db. The webservice should be the only one with the password, and it should get the data from the DB and return it in json or xml format.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I've started using webservice, but I still have the same problem ! I can send packets to the server only if I'm in the same network as the server ! thats because i'm still using 192.168.1.7 as the IP address of the server. With which IP address should I replace it to make it work even if I try it in another network ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.