简体   繁体   English

如何使用Java显示来自sql server的数据[android studio]

[英]How to display data from sql server with java [android studio]

I wish to display some data from my SQL server into my application. 我希望将一些数据从我的SQL Server显示到我的应用程序中。

Let me explain throw an example what have i done until now, and please tell me how should i go on with my work: 让我解释一个例子,说明我到目前为止所完成的工作,然后告诉我应该如何进行工作:

(1) I have a database named: 'DB1' (2) In my database i have table named 'users': (1)我有一个名为“ DB1”的数据库(2)在我的数据库中,有一个名为“ users”的表:

Id, Name, LastName
1   Dave  Stone
2   Rose  Mary
3   Gray  Lone

(3) I created 3 php files: 1/ config.php (sets up my database log in information like password...) 2/ DBConnection.php : ` (3)我创建了3个php文件:1 / config.php(设置数据库登录信息,例如密码...)2 / DBConnection.php:

// Connecting to database
public function connect() {
    require_once 'Config.php';

    // Connecting to mysql database
    $this->conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);

    // return database handler
    return $this->conn;
}
}

?>

3/ GetUsers.php which i dont know how should i write it - this would be the code which will echo whatever i want from the table. 3 / GetUsers.php,我不知道该怎么写- 这将是代码,它将回显我想要的表内容。

(4) Inside my android studio project i have a MainActivity.java and i want to get all the LastNames of all the users in the database and do whatever with them... like print them into a text box it doesn't really matter (let's say i don't know how many users I have). (4)在我的android studio项目中,我有一个MainActivity.java,我想获取数据库中所有用户的所有姓氏,并对其进行任何处理……就像将它们打印到文本框中一样,这并不重要(假设我不知道我有多少用户)。

I need some one to help me get stages (3)3/ + (4) done / explained. 我需要一些人来帮助我完成(3)3 / +(4)阶段的工作/解释。

I think what you mean is a good method to retrieve and set values from app to database, the best and most prominent way is using basic REST services that convert your db values to JSON then you load the json using your api key as authentication, it might sound really stressful but is in fact very easy and flexible to implement, the only way you can directly set and get db values on android is using sqlite (android local inbuilt db) 我认为您的意思是从应用程序检索和设置值到数据库的好方法,最好和最主要的方法是使用基本的REST服务,将db值转换为JSON,然后使用api密钥作为身份验证来加载json,听起来可能有些压力,但实际上实施起来非常容易且灵活,您可以在android上直接设置和获取db值的唯一方法是使用sqlite(Android本地内置db)

The best tutorial and major explanation for exactly what you want to achieve is here 有关您想要实现的目标的最佳教程和主要解释在这里

http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/ http://www.androidhive.info/2014/01/how-to-create-rest-api-for-android-app-using-php-slim-and-mysql-day-12-2/

Then this one for further works http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ 然后,这个用于进一步的工作http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

It covers how you make a rest service yourself 它涵盖了您如何自己提供休息服务

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将来自SQL Server查询的数据显示到android表中 - How to display data from a SQL Server query into android tables 从 sql 服务器检索数据对应于 Android Studio 中的 Edittext 值 - Retrieve data from sql server correspond to Edittext value in Android Studio Android Studio SQL / Java-从单独的视图检索数据 - Android Studio SQL/Java - retrieving data from separate view 如何在 android 工作室中从服务器显示 fonts 的预览 - how to display preview of fonts from server in android studio 如何在java [android studio]中将所有SQL表数据插入到数组中 - How to insert all the SQL table data into an array in java [android studio] 如何使用Java从加载为文件的Parse服务器加载图像并将其显示到Android Studio中的自定义ListView? - How to load images from Parse-server that is stored as file and display it to custom ListView in Android-Studio using Java? Android Studio,如何从Sqlite数据库中检索数据并将其显示到textview中? - Android Studio, how to retrieve data from Sqlite database and display it into textview? mysql数据库中android工作室的一个项目中的数据如何显示? - How to display the data in a project in android studio from mysql database? 如何使用JDBC在ListView或TableView中显示来自SQL Server的数据 - How to display data from SQL Server in a ListView or TableView using JDBC 从Android Studio比较SQL Server中的表 - Compare Tables In SQL server from android studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM