Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 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. public class MainActivity extends AppCompatActivity {
  9. @Override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.activity_main);
  13. }
  14. public static void main(String[] args) {
  15. Connection myconObj = null;
  16. Statement mystatObj = null;
  17. ResultSet myresObj = null;
  18. String query = "SELECT * FROM tbl_client";
  19. try {
  20. myconObj = DriverManager.getConnection("jdbc:mysql://localhost:8080/parking", "root", "Qwerty123@");
  21. mystatObj = myconObj.createStatement();
  22. myresObj = mystatObj.executeQuery(query);
  23. while(myresObj.next()) {
  24. int id = myresObj.getInt(1);
  25. String name = myresObj.getString(2);
  26. String username = myresObj.getString(3);
  27. String password = myresObj.getString(4);
  28. System.out.println(id +"\t "+ name +"\t "+ username + "\t " + password);
  29. }
  30. }
  31.  
  32. catch (SQLException e){
  33. e.printStackTrace();
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement