Guest User

Untitled

a guest
Jan 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. Button btn;
  2. EditText et;
  3. Connection con;
  4. String prueba, un, pass, db, ip;
  5. Statement stt;
  6. TextView t;
  7. @Override
  8. protected void onCreate(Bundle savedInstanceState) {
  9. super.onCreate(savedInstanceState);
  10. setContentView(R.layout.activity_main);
  11.  
  12. btn = (Button) findViewById(R.id.button);
  13. et = (EditText) findViewById(R.id.editText);
  14.  
  15. //ip = "145.14.144.52";
  16. t = findViewById(R.id.textView);
  17. t.setVisibility(View.INVISIBLE);
  18. db = "id3001279_unasproofs";
  19. ip = "jdbc:mysql://000webhost.com:3306/"+db;
  20. un = "id3001279_unasproofs";
  21. pass = "******";
  22.  
  23. btn.setOnClickListener(new View.OnClickListener() {
  24. @Override
  25. public void onClick(View view) {
  26. prueba = et.getText().toString();
  27. try {
  28. Class.forName("com.mysql.jdbc.Driver");
  29. //.newInstance();
  30. con = (Connection) DriverManager.getConnection(ip, un, pass);
  31. stt = con.createStatement();
  32. String query = "INSERT INTO txumino VALUES(" +et.getText().toString() + ");";
  33. ResultSet rs = stt.executeQuery(query);
  34. }catch (Exception e){
  35. t.setVisibility(View.VISIBLE);
  36. }
  37.  
  38.  
  39. }
  40. });
  41. }
Add Comment
Please, Sign In to add comment