Tony
Tony

Reputation: 507

Android sql database

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

Upvotes: 2

Views: 168

Answers (1)

rekire
rekire

Reputation: 47985

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.

Upvotes: 4

Related Questions