what ever I did I get the same error NO SUITABLE DRIVER
I have sql server 2014 and I am using Eclipse mars
I tried every jtds i found no solution
I am new on android and java,
i really need help.
ListView lv = null;
Connection connx = null;
SimpleAdapter sa = null;
String sqlreq = "select * from news";
@SuppressLint("NewApi")
private Connection cnx() //connection to sqlserver
{
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:jdts:sqlserver://xxxxxx:1433;DatabaseName=xxxx;ssl=require";
conn=DriverManager.getConnection(ConnUrl);
} catch (SQLException e)
{
Log.e("Error", e.getMessage());
}
catch (ClassNotFoundException e)
{
Log.e("Error", e.getMessage());
}
catch (Exception e)
{
Log.e("Error", e.getMessage());
}
return conn;
}
public void SqlQuery(String SqlCmnd)
{
connx = cnx();
ResultSet rs;
try
{
Statement stm = connx.createStatement();
rs = stm.executeQuery(SqlCmnd);
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("title"));
datanum.put("B", rs.getString("idnews"));
data.add(datanum);
}
String[] from = {"A","B"};
int [] views ={R.id.Titleid,R.id.Articleid};
sa = new SimpleAdapter(this, data, R.layout.model, from, views);
lv.setAdapter(sa);
}
catch (Exception e) {
Log.e("Error", e.getMessage());
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lv = (ListView)findViewById(R.id.listView1);
setContentView(R.layout.activity_main);
SqlQuery(sqlreq);
}