Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package com.example.gilbertojimenezorench.myapp;
  2.  
  3. import android.annotation.SuppressLint;
  4. import android.os.StrictMode;
  5. import android.util.Log;
  6.  
  7. import java.sql.Connection;
  8. import java.sql.DriverManager;
  9. import java.sql.SQLException;
  10.  
  11. /**
  12. * Created by gilbertojimenezorench on 10/14/16.
  13. */
  14.  
  15. public class ConnectionClass {
  16.  
  17. String ip = "mysqldb.capscbgbnhob.us-west-2.rds.amazonaws.com:3306";
  18. String classs = "net.sourceforge.jtds.jdbc.Driver";
  19. String db = "mysqldb";
  20. String un = "poastgres";
  21. String password = "password0987";
  22.  
  23. @SuppressLint("NewApi")
  24. public Connection CONN() {
  25. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
  26. .permitAll().build();
  27. StrictMode.setThreadPolicy(policy);
  28. Connection conn = null;
  29. String ConnURL = null;
  30. try {
  31.  
  32. Class.forName(classs);
  33. ConnURL = "jdbc:jtds:sqlserver://" + ip + ";"
  34. + "databaseName=" + db + ";user=" + un + ";password="
  35. + password + ";";
  36. conn = DriverManager.getConnection(ConnURL);
  37. } catch (SQLException se) {
  38. Log.e("ERRO", se.getMessage());
  39. } catch (ClassNotFoundException e) {
  40. Log.e("ERRO", e.getMessage());
  41. } catch (Exception e) {
  42. Log.e("ERRO", e.getMessage());
  43. }
  44. return conn;
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement