Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button btn;
- EditText et;
- Connection con;
- String prueba, un, pass, db, ip;
- Statement stt;
- TextView t;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- btn = (Button) findViewById(R.id.button);
- et = (EditText) findViewById(R.id.editText);
- //ip = "145.14.144.52";
- t = findViewById(R.id.textView);
- t.setVisibility(View.INVISIBLE);
- db = "id3001279_unasproofs";
- ip = "jdbc:mysql://000webhost.com:3306/"+db;
- un = "id3001279_unasproofs";
- pass = "******";
- btn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- prueba = et.getText().toString();
- try {
- Class.forName("com.mysql.jdbc.Driver");
- //.newInstance();
- con = (Connection) DriverManager.getConnection(ip, un, pass);
- stt = con.createStatement();
- String query = "INSERT INTO txumino VALUES(" +et.getText().toString() + ");";
- ResultSet rs = stt.executeQuery(query);
- }catch (Exception e){
- t.setVisibility(View.VISIBLE);
- }
- }
- });
- }
Add Comment
Please, Sign In to add comment