private String user = "sa"; private String password = "hello@12345"; private String database = "test"; private String server = "192.168.1.89"; private String ConnectionURL; connectionHelper(user,password,database,server); private Connection connectionHelper(String user, String password, String database, String server){ StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); try { try { Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } ConnectionURL = "jdbc:jtds:sqlserver://" + server + ";" + "databaseName=" + database + ";user=" + user + ";password=" + password + ";"; try { connection = DriverManager.getConnection(ConnectionURL); if( connection != null ) { Log.d("TAG", "Connected To SQLServer"); } else { Log.d("TAG", "Error in Connecting To SQLServer"); } } catch (SQLException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); } return connection; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)