database connection - Android app error when trying to connect to SQL Server 2005 -


good day!

i following tutorial - http://www.youtube.com/watch?v=eismgy9ucii

and tried connect android application sql server 2005. application should data database , display in emulator. now, i'm stuck unknown error, when running application displays empty screen , message "" , no errors occur in console or logcat.

here first_activity.java code:

public class first_activity extends activity {  // creating objects button executar; edittext valorbusca; listview lista; connection connect; simpleadapter ad;  //declaring objects     private void declarar()     {         executar = (button) findviewbyid(r.id.btn_buscar);         valorbusca = (edittext) findviewbyid(r.id.txt_buscar);         lista = (listview) findviewbyid(r.id.list_output);     }  //initialize objects  private void inicializar() {            declarar(); valorbusca.settext("select id_pl, pl_name planogram_head"); connect = conn("sa", "zxc123456", "market", "10.0.2.2:1433"); }  //create classes @suppresslint("newapi") private connection conn (string _user, string _pass, string _db, string _server) {     strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();     strictmode.setthreadpolicy(policy);     connection conn = null;     string connurl = null;     try {         class.forname("net.sourceforge.jtds.jdbc.driver");         connurl = "jdbc:jtds:sqlserver://"+ _server + ";" + "databasename=" + _db + ";user=" + _user + ";password=" + _pass + ";";         conn = drivermanager.getconnection(connurl);      } catch (sqlexception se) {         log.e("error", se.getmessage());     } catch (classnotfoundexception e) {         log.e("error", e.getmessage());     } catch (exception e) {         log.e("error", e.getmessage());     }     system.out.println("connected");     return conn; }   public void querysql (string comandosql) {     resultset rs;     try {         statement statement = connect.createstatement();         rs = statement.executequery(comandosql);         //configuring of simple adapter          list<map<string, string>> data = null;         data = new arraylist<map<string, string>>();          while(rs.next()) {             map<string, string> datanum = new hashmap<string, string>();             datanum.put("a", rs.getstring("id_pl"));             datanum.put("b", rs.getstring("pl_name"));             data.add(datanum);         }          string[] = {"a", "b"};         int[] views = {r.id.tex_title, r.id.text_content};         ad = new simpleadapter(this, data, r.layout.model, from, views);         lista.setadapter(ad); } catch (exception e) {         log.e("error", e.getmessage());     }  }  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.first_activity);      inicializar();     executar.setonclicklistener(new onclicklistener () {         public void onclick(view v){             querysql(valorbusca.gettext().tostring());         }     }); } 

}

i found problem. entire code correct, needed add "instance" url , set allip = 1433 in "sql server configuration manager".

thanks attention! br, makpal


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -