Advertisement
Guest User

Untitled

a guest
Jul 16th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. public void connectionToDataBase()
  2. {
  3. try
  4. {
  5. TextView textViewWhere = (TextView) findViewById(R.id.dateStart);
  6. TextView textViewFrom = (TextView)findViewById(R.id.dateEnd);
  7. EditText editTextTickets = (EditText)findViewById(R.id.tickets);
  8. String userName = "1111";
  9. String password = "1111";
  10. String url = "jdbc:mysql://77.87.193.68/abcd";
  11. Class.forName ("com.mysql.jdbc.Driver").newInstance ();
  12. conn = DriverManager.getConnection (url, userName, password);
  13. String insertDataIntoSQL = "INSERT INTO BUS_ORDER(pay_status, real_date_from, real_date_back)values('no', '" + textViewFrom.getText() +"', '" +textViewWhere.getText() +"')";
  14. Statement statement = conn.createStatement();
  15. statement.executeUpdate(insertDataIntoSQL);
  16. }
  17. catch (Exception e)
  18. {
  19. System.err.println ("Cannot connect to database server");
  20. e.printStackTrace();
  21. }
  22. finally {
  23. if(conn != null)
  24. {
  25. try{
  26. conn.close();
  27. }
  28. catch(Exception e)
  29. {}
  30. }
  31. }
  32.  
  33. }
  34. public void Bronirovat(View v)
  35. {
  36. connectionToDataBase();
  37. startActivity(new Intent(this, Tickets.class));
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement