How to access sql server database, which is using windows authentication, using android -


i have access sql server database using windows authentication log in.the exception says user can't authenticated, because server using windows login instead of sql login? also, user account has no password, default admin account, have specify differently when trying connect database? know not new question , problem has been solved please assist me working solution. have following code:

import android.os.asynctask; import android.os.strictmode; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.textview; import java.sql.connection; import java.sql.driver; import java.sql.drivermanager; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.sqlexception; import java.sql.statement; import java.util.properties;  public class mainactivity extends appcompatactivity {  textview tvtest; connection connection; string un,password,db,ip; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     tvtest = (textview) findviewbyid(r.id.tvtest);      ip = "ip server";     db = "database use";     un = "administrator";     password = "there no password";  }  public class connecttoserver extends asynctask<string,string,string> {     string message;      @override     protected void onpreexecute() {         super.onpreexecute();     }      @override     protected void onpostexecute(string s) {         tvtest.settext(message);     }      @override     protected string doinbackground(string... params) {           message = null;       try {           connection = connectionclass();            if (connection == null)           {                message = "no internet connection";           }else           {               preparedstatement statement =   connection.preparestatement("exec testprocedure");               resultset resultset = statement.executequery();               if (resultset.next())               {                  message = resultset.getstring("test1");               } else               {                   message = "invalid";               }           }       }        catch (exception ex)       {           log.v("error",ex.getmessage());       }         return  message;     } }  public connection connectionclass() {     strictmode.threadpolicy policy = new strictmode.threadpolicy.builder().permitall().build();     strictmode.setthreadpolicy(policy);     connection connection = null;     string connectionurl = null;     try {         class.forname("net.sourceforge.jtds.jdbc.driver");          connectionurl = "jdbc:jtds:sqlserver://" + ip + ";"                 + "databasename=" + db + ";user=" + un + ";password="                 + password + ";";         connection = drivermanager.getconnection(connectionurl);     }     catch (sqlexception se)     {         log.e("sql error:",se.getmessage());     }     catch (classnotfoundexception e)     {         log.e("class error:", e.getmessage());     }     catch (exception e)     {         log.e("error:", e.getmessage());     }     return connection; }  public void btntest(view view) {     connecttoserver connecttoserver = new connecttoserver();     connecttoserver.execute(""); } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -