Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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. }
  17. public static void main(String[] args) {
  18. Connection myconObj = null;
  19. Statement mystatObj = null;
  20. ResultSet myresObj = null;
  21.  
  22.  
  23. String query = "SELECT * FROM tbl_client";
  24. try {
  25. myconObj = DriverManager.getConnection("jdbc:mysql://localhost:8080/parking", "root", "Qwerty123@");
  26. mystatObj = myconObj.createStatement();
  27. myresObj = mystatObj.executeQuery(query);
  28. while(myresObj.next()) {
  29. int id = myresObj.getInt(1);
  30. String name = myresObj.getString(2);
  31. String username = myresObj.getString(3);
  32. String password = myresObj.getString(4);
  33. output = id + "\t " + name + "\t " + username + "\t " + password;
  34. }
  35. }
  36.  
  37. catch (SQLException e){
  38. e.printStackTrace();
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement