Guest User

Untitled

a guest
Oct 1st, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. package project_aps.apps;
  2.  
  3. /**
  4. * Created by ph_rp on 28/09/2016.
  5. */
  6. import java.sql.Connection;
  7. import java.sql.DriverManager;
  8. import java.sql.ResultSet;
  9. import java.sql.Statement;
  10. import android.util.Log;
  11.  
  12. public class sqlController {
  13.  
  14. public String driver;
  15. public String url;
  16. public String user;
  17. public String password;
  18.  
  19. //-- CRIANDO CONEXOES
  20. public static Connection conn;
  21. public static Statement stmt;
  22. public static ResultSet rs;
  23.  
  24. public sqlController() {
  25. driver = "com.mysql.jdbc.Driver";
  26. url = "jdbc:mysql://192.168.0.22:3306/appsocial";
  27. user = "apps";
  28. password = "001200";
  29. }
  30.  
  31. public boolean Conecta() throws Exception
  32. {
  33. try {
  34. Class.forName(driver).newInstance ();
  35. Log.w("BLOQUEIO","TUDO OK COM CLASS.FORNAME");
  36. } catch (Exception e) {
  37. Log.w("BLOQUEIO","NAO FUNCIONOU O CLASS.FORNAME");
  38. }
  39.  
  40. try {
  41. conn = DriverManager.getConnection(url,user,password);
  42. Log.w("BLOQUEIO","TUDO OK COM O DRIVER.MANAGER");
  43. } catch (Exception e) {
  44. Log.w("BLOQUEIO",e.getMessage());
  45. }
  46.  
  47. try {
  48. stmt = conn.createStatement();
  49. Log.w("BLOQUEIO","TUDO OK COM O CREATESTATEMENT");
  50. } catch (Exception e) {
  51. Log.w("BLOQUEIO","NAO FUNCIONOU O CREATESTATEMENT");
  52. }
  53.  
  54.  
  55. return true;
  56. }
  57. }
Add Comment
Please, Sign In to add comment