Guest User

Untitled

a guest
Nov 28th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. public class ConnectionDB {
  2. String ip = "192.168.1.103";
  3. String classs = "net.sourceforge.jtds.jdbc.Driver";
  4. String db = "Andro";
  5. String un = "abc";
  6. String password = "1";
  7.  
  8. @SuppressLint("NewApi")
  9. public Connection CONN() {
  10. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
  11. .permitAll().build();
  12. StrictMode.setThreadPolicy(policy);
  13. Connection conn = null;
  14. String ConnURL = null;
  15. try {
  16.  
  17. Class.forName(classs);
  18. ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
  19. + "databaseName=" + db + ";user=" + un + ";password="
  20. + password + ";";
  21. conn = DriverManager.getConnection(ConnURL);
  22. } catch (SQLException se) {
  23. Log.e("ERRO", se.getMessage());
  24. } catch (ClassNotFoundException e) {
  25. Log.e("ERRO", e.getMessage());
  26. } catch (Exception e) {
  27. Log.e("ERRO", e.getMessage());
  28. }
  29. return conn;
  30. }
  31. }
  32.  
  33. ConnectionDB con=new ConnectionDB();
  34. if (!TextUtils.isEmpty(password) &&!TextUtils.isEmpty(email)) {
  35. try {
  36. if (con == null) {
  37. alertDialog.setMessage("Cannot Access To Server");
  38. } else {
  39. String query = "Select * from Partner where lower(username)=lower('" + email + "') and password=N'" + password + "'";
  40. Statement stmt = con.createStatement();
  41. ResultSet rs = stmt.executeQuery(query);
  42.  
  43. if (rs.next()) {
  44.  
  45. alertDialog.setMessage("Success");
  46.  
  47. } else {
  48. alertDialog.setMessage("Fail");
  49. }
  50.  
  51. }
  52. } catch (Exception ex) {
  53. z = "Exceptions";
  54. }
  55. }
Add Comment
Please, Sign In to add comment