public class ConnectionTask extends AsyncTask<void,> { Connection conn = null; String connString = "jdbc:jtds:sqlserver://localhost:1433/Sample"; @Override protected String doInBackground(Void... params) { try { String driver = "net.sourceforge.jtds.jdbc.Driver"; Class.forName(driver); String username = ""; String password = ""; conn = DriverManager.getConnection(connString,username,password); Log.d("Connection","open"); Statement stmt = conn.createStatement(); ResultSet reset = stmt.executeQuery("select * from sree"); //Print the data to the console while(reset.next()){ Log.d("Data:",reset.getString(1)); } conn.close(); } catch (Exception e) { Log.d("Error connection","" + e.getMessage()); } return null; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)