Hi,
I need code of connectivity between android and sql server. Please help.. Its important.
Thanks in advance!
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Joginder BangerRank #360 · 7K reputationPosted Sep 11, 2015, 9:24 PM EDT
importjava.sql.Connection;02importjava.sql.DriverManager;03importjava.sql.ResultSet;04importjava.sql.Statement;0506importnet.sourceforge.jtds.jdbc.*;0708publicvoidquery2()09{10Log.i("Android"," MySQL Connect Example.");11Connection conn =null;12try{13String driver ="net.sourceforge.jtds.jdbc.Driver";14Class.forName(driver).newInstance();15//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;16String connString ="jdbc:jtds:sqlserver://server_ip_address:1433/DBNAME;encrypt=fasle;user=xxxxxxxxx;password=xxxxxxxx;instance=SQLEXPRESS;";17String username ="xxxxxx";18String password ="xxxxxxxxxx";19conn = DriverManager.getConnection(connString,username,password);20Log.w("Connection","open");21Statement stmt = conn.createStatement();22ResultSet reset = stmt.executeQuery("select * from TableName");2324//Print the data to the console25while(reset.next()){26Log.w("Data:",reset.getString(3));27// Log.w("Data",reset.getString(2));28}29conn.close();3031}catch(Exception e)32{33Log.w("Error connection",""+ e.getMessage());34}35}