Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.kamil.sql;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import java.sql.*;
- import java.lang.String;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Connection myconObj = null;
- Statement mystatObj = null;
- ResultSet myresObj = null;
- String output = "";
- String query = "SELECT * FROM tbl_client";
- try {
- myconObj = DriverManager.getConnection("jdbc:mysql://localhost:8080/parking", "root", "Qwerty123@");
- mystatObj = myconObj.createStatement();
- myresObj = mystatObj.executeQuery(query);
- while(myresObj.next()) {
- int id = myresObj.getInt(1);
- String name = myresObj.getString(2);
- String username = myresObj.getString(3);
- String password = myresObj.getString(4);
- output = id + "\t " + name + "\t " + username + "\t " + password;
- }
- }
- catch (SQLException e){
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement