2

I try to connect from eclipse emulator android to an sql server using this code:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
String connString = "jdbc:jtds:sqlserver://83.212.240.15:1521/hua;encrypt=false;user=xxxxxx;password=xxx;instance=SQLEXPRESS;";
String username = "xxxxx";
String password = "xxxxx";
conn = DriverManager.getConnection(connString,username,password);
Statement stmt = conn.createStatement();
ResultSet reset = stmt.executeQuery("insert into picture values('hi');");
conn.close();

but in the database nothing happens.Any ideas?

Thanks in adnvanced

2
  • 1
    Check your spelling for String connString = "jdbc:jtds:sqlserver://83.212.240.15:1521/hua;encrypt=false;user=xxxxxx;password=xxx;instance=SQLEXPRESS;"; You mispelled FALSE Commented Jun 16, 2013 at 18:36
  • Still nothing happens Commented Jun 16, 2013 at 18:38

1 Answer 1

4

Well this is not directly the answer you are expecting but I would not suggest to access a database directly. Better use e.g. a REST webservice for all database access. So you don't need to make your credentials public.

It is quiet simple so observe the network traffic so it would be realy easy to hack you database server(s).

Anyway if your App is really only for private usage you need to check that you app has the Internet permission for accessing your network ressources.

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

3 Comments

Yes it has the persmission.
Which exceptions do you get exactly? Can you provide a stacktrace from the logcat?
I don't have any excetpions the program runs well

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.