Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package com.example.kamil.sql;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import java.sql.*;
  6. import java.lang.String;
  7.  
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13. setContentView(R.layout.activity_main);
  14.  
  15.  
  16. Connection myconObj = null;
  17. Statement mystatObj = null;
  18. ResultSet myresObj = null;
  19. String output = "";
  20.  
  21. String query = "SELECT * FROM tbl_client";
  22. try {
  23. myconObj = DriverManager.getConnection("jdbc:mysql://localhost:8080/parking", "root", "Qwerty123@");
  24. mystatObj = myconObj.createStatement();
  25. myresObj = mystatObj.executeQuery(query);
  26. while(myresObj.next()) {
  27. int id = myresObj.getInt(1);
  28. String name = myresObj.getString(2);
  29. String username = myresObj.getString(3);
  30. String password = myresObj.getString(4);
  31. output = id + "\t " + name + "\t " + username + "\t " + password;
  32.  
  33. }
  34. }
  35.  
  36. catch (SQLException e){
  37. e.printStackTrace();
  38. }
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement