Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. private static Connection conexionMySQL = null;
  2.  
  3. public static void CreaConexion (Context context, String usuario, String pass, String ip, String puerto, String catalogo)
  4. {
  5. if (conexionMySQL == null)
  6. {
  7. String urlConexionMySQL = "";
  8.  
  9. if (catalogo != "")
  10. {
  11. urlConexionMySQL = "jdbc:mysql://address=(protocol=tcp)(host="+ip+")(port="+puerto+")(user=root)/"+catalogo+"";
  12. }
  13. else
  14. urlConexionMySQL = "jdbc:mysql://address=(protocol=tcp)(host="+ip+")(port="+puerto+")(user=root)/";
  15.  
  16. if (usuario != "" & pass != "" & ip != "" & puerto != "")
  17. {
  18. try
  19. {
  20. Class.forName("com.mysql.jdbc.Driver");
  21.  
  22. Toast.makeText(context, urlConexionMySQL, Toast.LENGTH_LONG).show();
  23.  
  24. conexionMySQL = DriverManager.getConnection(urlConexionMySQL, usuario, pass);
  25. }
  26. catch (ClassNotFoundException e)
  27. {
  28. Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
  29. }
  30. catch (SQLException e)
  31. {
  32. Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
  33. }
  34. }
  35. }
  36. }
  37.  
  38. # SERVER SECTION
  39. # ----------------------------------------------------------------------
  40. #
  41. # The following options will be read by the MySQL Server. Make sure that
  42. # you have installed the server correctly (see above) so it reads this
  43. # file.
  44. #
  45. # server_type=3
  46. [mysqld]
  47.  
  48. # The next three options are mutually exclusive to SERVER_PORT below.
  49. # skip-networking
  50. # enable-named-pipe
  51. # The Pipe the MySQL Server will use
  52. # socket=mysql
  53.  
  54. # The TCP/IP Port the MySQL Server will listen on
  55. port=3306
  56. bind-address=*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement