Guest User

Untitled

a guest
Jul 8th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
  2.  
  3. NetworkInfo netInfo = cm.getActiveNetworkInfo();
  4.  
  5. if (netInfo != null && netInfo.isConnectedOrConnecting()) {
  6.  
  7. Toast.makeText(getApplicationContext(), "Conectado a Internet", Toast.LENGTH_SHORT).show();
  8.  
  9. } else {
  10.  
  11. Toast.makeText(getApplicationContext(), "No Conectado", Toast.LENGTH_SHORT).show();
  12.  
  13. }
  14.  
  15. Connection connection = null;
  16. String ConnectionURL, servidor, db, usuario, password;
  17.  
  18. servidor = "192.168.0.10";
  19. db="ComercializacionYMarketing";
  20. usuario="sa";
  21. password="314159265";
  22. try {
  23. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  24. StrictMode.setThreadPolicy(policy);
  25.  
  26. Class.forName("net.sourceforge.jtds.jdbc.Driver");
  27. ConnectionURL = "jdbc:jtds:sqlserver://"+servidor+";databaseName="+db+";user="+usuario+";password="+password+";";
  28. connection = DriverManager.getConnection(ConnectionURL);
  29. } catch (SQLException se) {
  30. Log.e("bug", se.getMessage());
  31. } catch (ClassNotFoundException e) {
  32. Log.e("bug", e.getMessage());
  33. } catch (Exception e) {
  34. Log.e("bug", e.getMessage());
  35. }
  36. }
Add Comment
Please, Sign In to add comment