Android-studio 学生管理系统数据库的使用(云数据库与本地数据库的增删改查,上传,下载)

Android-studio 学生管理系统数据库的使用(云数据库与本地数据库的上传,下载)功能实现本地数据库sqlite的增删改查实现云数据库的增删改查(腾讯云为例)实现上传,下载。云数据库的连接1.AndroidManifest.xml中添加 <uses-permission android:name="android.permission.INTERNET" />2.连接数据库语句 Class.forName("com.mysql.jdbc.Driver");
摘要由CSDN通过智能技术生成

Android-studio 学生管理系统数据库的使用(云数据库与本地数据库的上传,下载)

功能

  • 实现本地数据库sqlite的增删改查
  • 实现云数据库的增删改查(腾讯云为例)
  • 实现上传,下载。

云数据库的连接

1.AndroidManifest.xml中添加

  <uses-permission android:name="android.permission.INTERNET" />

2.连接数据库语句

  Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql://(云数据库的外网地址).com:61963/(数据库名)?+(时区)";
        String name =“数据库登录账号”;
        String passwd =”数据库登录密码“;
        Connection connection = DriverManager.getConnection(url,name,passwd);

3.导入mysql-connector-java-5.1.23-bin.jar

代码

布局(.xml)

登录页面(activity_main.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:background="#7DD0F3"
    tools:context=".MainActivity">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="学生管理"
    android:textStyle="bold"
    android:textColor="#385AC3"
    android:textSize="15pt"
    android:paddingLeft="60pt"/>
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/et_stuId"
    android:hint="请输入学号"></EditText>
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/et_stuName"
    android:hint="请输入姓名"></EditText>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <Button
            android:layout_width="wrap_content"
            android:id="@+id/btn_login1"
            android:text="登录本地数据库"
            android:layout_height="wrap_content"></Button>
        <Button
            android:layout_width="wrap_content"
            android:id="@+id/btn_login2"
            android:text="登录云数据库"
            android:layout_height="wrap_content"></Button>

    </LinearLayout>
</LinearLayout>
云端界面(yunpage.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".YunpageActivity">
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="请输入学号"
    android:id="@+id/et_stuId1"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_stuName1"
        android:hint="请输入姓名"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_major"
        android:hint="请输入专业"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_class"
        android:hint="请输入班级"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/et_grade"
        android:hint="请输入成绩"></EditText>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btn_show"
        android:text="显示"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="插入"
        android:id="@+id/btn_insert"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="删除"
        android:id="@+id/btn_del"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="修改"
        android:id="@+id/btn_change"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btn_person"
        android:text="查询个人信息"></Button>
    <Button
        android:layout_width="wrap_content"
        android:id="@+id/btn_download"
        android:text="下载"
        android:layout_height="wrap_content"></Button>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/tv_show"></TextView>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_view"/>
</LinearLayout>
本地界面(localpage.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".LocalpageActivity">
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/list_view"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="新建"
        android:id="@+id/btn_new_note"/>
</LinearLayout>
本地修改数据与上传界面(new_local_page.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".NewLocalPageActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入学号"
        android:id="@+id/et_title">
    </EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入姓名"
        android:id="@+id/et_content"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入专业"
        android:id="@+id/et_local_major"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入班级"
        android:id="@+id/et_local_class"></EditText>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入成绩"
        android:id="@+id/et_local_grade"></EditText>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="提交"
        android:id="@+id/btn_submit"></Button>
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="上传"
    android:id="@+id/btn_unload"></Button>
</LinearLayout>
本地数据库显示信息界面(listview_item.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    
  • 5
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值