Android : SQLite 增删改查—简单应用

示例图:

学生实体类 Student.java

package com.example.mysqlite.dto;public class Student {public Long id;public String name;public String sex;public int age;public String clazz;public String creatDate;//头像public byte[] logoHead;@Overridepublic String toString() {return "Student{" +"id=" + id +", name='" + name + '\'' +", sex='" + sex + '\'' +", age=" + age +", clazz='" + clazz + '\'' +", creatDate='" + creatDate + '\'' +'}';}
}

工具类 DBhelpUtil.java

package com.example.mysqlite.util;import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import android.widget.Toast;import androidx.annotation.Nullable;public class DBhelpUtil extends SQLiteOpenHelper {/**数据库名字*/public static final String DB_NAME = "studentDB";/**学生表字段信息*/public static final String TABLE_NAME = "tb_student";public static final String TB_NAME = "name";public static final String TB_SEX = "sex";public static final String TB_AGE = "age";public static final String TB_CLAZZ = "clazz";public static final String TB_CREATEDATE = "createDate";/**数据版本号 第一次运行要打开 */
//    public static final int DB_VERSION = 1;//模拟数据版本升级public static final int DB_VERSION = 2;/**** @param context   上下文* @param name      数据库名字* @param factory   游标工厂 null* @param version   自定义的数据库版本*/public DBhelpUtil(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {super(context, name, factory, version);}//数据库第一次创建时被调用@Overridepublic void onCreate(SQLiteDatabase db) {//初始化 第一次 创建数据库StringBuilder sql = new StringBuilder();sql.append(" create table tb_student(");sql.append(" id integer primary key,  ");sql.append(" name varchar(20),");sql.append(" sex varchar(2),");sql.append(" age varchar(20),");sql.append(" clazz varchar(20),");sql.append(" createDate varchar(23) )");//        Log.e("TAG","------"+sql.toString());//执行sqldb.execSQL(sql.toString());}//版本号发生改变时调用@Overridepublic void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {//更新数据库 插入字段String sql = "alter table tb_student add logoHead varchar(200)";db.execSQL(sql);}
}

StudentDao.java

package com.example.mysqlite.dao;import android.content.ContentValues;
import android.content.Context;
import android.database.AbstractWindowedCursor;
import android.database.Cursor;
import android.database.CursorWindow;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;import com.example.mysqlite.dto.Student;
import com.example.mysqlite.util.DBhelpUtil;import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.SimpleFormatter;public class StudentDao {private DBhelpUtil dBhelpUtil;/**相当于获得一个链接数据库的对象*/private SQLiteDatabase DB;private Context context;public StudentDao(Context context,DBhelpUtil dBhelpUtil){this.context =context;this.dBhelpUtil = dBhelpUtil;}//保存数据public Long save(Student student) {/** 获取一个写 操作数据的对象*/DB = dBhelpUtil.getWritableDatabase();ContentValues contentValues = new ContentValues();contentValues.put(DBhelpUtil.TB_NAME,student.name);contentValues.put(DBhelpUtil.TB_SEX,student.sex);contentValues.put(DBhelpUtil.TB_AGE,student.age);contentValues.put(DBhelpUtil.TB_CLAZZ,student.clazz);//        Log.e("TAG","--------------"+student.toString());
//        Toast.makeText(context,"sql 语句--"+student.toString(),Toast.LENGTH_LONG).show();//时间Date date = new Date();//格式化SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");contentValues.put(DBhelpUtil.TB_CREATEDATE, simpleDateFormat.format(date));/**insert()* String table: 表名* String nullColumnHack: 不允许插入空行,为了防止插入空行,可以在这里随便指定一列, 如果有空值插入 会用null表示,好像没作用~* ContentValues values 数据行数据* 返回值 成功插入行号的id  ,插入失败 -1*/return DB.insert(DBhelpUtil.TABLE_NAME,"空值",contentValues);//INSERT INTO tb_student(id,age,sex,name,clazz,createDate) VALUES (?,?,?,?,?,?)}/**查询数据*/public List<Student> select(Long id) {/** 获取一个读 操作数据的对象*/DB =dBhelpUtil.getReadableDatabase();/**query() 查询数据*String table, 表名* String[] columns, 要查询要显示的列* String selection,   查询条件* String[] selectionArgs, 参数值* String groupBy, 分组* String having, 分组后的条件* String orderBy 排序* 返回游标 Cursor*/String[] columns = new String[]{"id",DBhelpUtil.TB_NAME,DBhelpUtil.TB_SEX,DBhelpUtil.TB_AGE,DBhelpUtil.TB_CLAZZ,DBhelpUtil.TB_CREATEDATE};Cursor cursor = null;if(id == null){//全查cursor = DB.query(DBhelpUtil.TABLE_NAME,columns,null,null,null,null,"id desc");}else {//根据id 查询cursor = DB.query(DBhelpUtil.TABLE_NAME,columns,"id=?",new String[]{String.valueOf(id)},null,null,null);}List<Student> studentList = new ArrayList<>();if(cursor != null){//遍历游标while(cursor.moveToNext()){Student student = new Student();// 根据游标找到列  在获取数据student.id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));student.name = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_NAME));student.sex = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_SEX));student.age = cursor.getInt(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_AGE));student.clazz = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CLAZZ));student.creatDate = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CREATEDATE));//添加到集合studentList.add(student);}}cursor.close();return studentList;}/**删除数据*/public int delete(Long id) {// 获取操作数据库对象DB = dBhelpUtil.getWritableDatabase();/*** String table,  表名* String whereClause, 条件* String[] whereArgs 参数* 返回影响行数,失败 0*///全部删除if(id == null){return DB.delete(DBhelpUtil.TABLE_NAME,null,null);}// 条件查询return DB.delete(DBhelpUtil.TABLE_NAME,"id = ?",new String[]{id+""});}/**保存位图*/public void saveBitmap(Student student) {/** 获取一个写 操作数据的对象*/DB = dBhelpUtil.getWritableDatabase();//开启事务DB.beginTransaction();//时间Date date = new Date();//格式化SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//执行sql语句 方式String sql = "INSERT INTO tb_student(age,sex,name,clazz,createDate,logoHead) VALUES (?,?,?,?,?,?)";/*** sql 语句* 要插入的数据*/DB.execSQL(sql,new Object[]{student.age,student.sex,student.name,student.clazz,simpleDateFormat.format(date),student.logoHead});//设置事务成功DB.setTransactionSuccessful();//添加事务DB.endTransaction();}//查询位图public Student selectBitmapById(Long id) {/** 获取一个读 操作数据的对象*/DB =dBhelpUtil.getReadableDatabase();Cursor cursor = null;/** 根据id 查询 返回一个游标对象* String sql,* String[] selectionArgs,* select * from tb_student where id = ?*/cursor = DB.rawQuery("select * from "+ DBhelpUtil.TABLE_NAME+" where id =?",new String[]{id+""});// 解决报错;android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1CursorWindow cw = new CursorWindow("test", 5000000); // 设置CursorWindow的大小为5000000AbstractWindowedCursor ac = (AbstractWindowedCursor) cursor;ac.setWindow(cw);Student student = null;if(cursor != null){if(cursor.moveToNext()){student = new Student();// 根据游标找到列  在获取数据student.id = cursor.getLong(cursor.getColumnIndexOrThrow("id"));student.name = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_NAME));student.sex = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_SEX));student.age = cursor.getInt(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_AGE));student.clazz = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CLAZZ));student.creatDate = cursor.getString(cursor.getColumnIndexOrThrow(DBhelpUtil.TB_CREATEDATE));//图片student.logoHead =cursor.getBlob(cursor.getColumnIndexOrThrow("logoHead")) ;}}cursor.close();return student;}//按条件修改public int updateById(Student student,Long id){// 获取写操作数据库对象DB = dBhelpUtil.getWritableDatabase();//开启事务DB.beginTransaction();/*** String table,* ContentValues values, 数据行数据* String whereClause, 条件* String[] whereArgs   参数* 返回影响行数*///数据行数据ContentValues contentValues = new ContentValues();contentValues.put(DBhelpUtil.TB_NAME,student.name);contentValues.put(DBhelpUtil.TB_SEX,student.sex);contentValues.put(DBhelpUtil.TB_AGE,student.age);contentValues.put(DBhelpUtil.TB_CLAZZ,student.clazz);//时间Date date = new Date();//格式化SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");contentValues.put(DBhelpUtil.TB_CREATEDATE, simpleDateFormat.format(date));int result = DB.update(DBhelpUtil.TABLE_NAME,contentValues,"id = ?", new String[]{id+""});//完成事务DB.setTransactionSuccessful();//结束事务DB.endTransaction();return result;}
}

MainActivity.java

package com.example.mysqlite;import androidx.appcompat.app.AppCompatActivity;import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;import com.example.mysqlite.activity.BaseActivity;
import com.example.mysqlite.dao.StudentDao;
import com.example.mysqlite.dto.Student;
import com.example.mysqlite.util.DBhelpUtil;import java.io.ByteArrayOutputStream;
import java.util.List;public class MainActivity extends AppCompatActivity {private Context mContext;private EditText etName,etSex,etAge,etClass;private EditText etSelectID,etDeleteID;private Button btnSave,btnSelect,btnDelete,btnSaveBitmap,btnSelectBitmap,btnUpdate;private TextView textView;private ImageView imageView;private DBhelpUtil dBhelpUtil;private StudentDao studentDao;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mContext = this;etName = findViewById(R.id.et_name);etSex = findViewById(R.id.et_sex);etAge = findViewById(R.id.et_age);etClass = findViewById(R.id.et_class);etSelectID =findViewById(R.id.et_select_id);etDeleteID = findViewById(R.id.et_delete_id);textView =findViewById(R.id.tv_data);imageView = findViewById(R.id.iv_image);//按钮btnSave = findViewById(R.id.tbn_save);btnSelect = findViewById(R.id.tbn_select);btnDelete = findViewById(R.id.tbn_delete);btnSaveBitmap = findViewById(R.id.btn_save_bitmap);btnSelectBitmap = findViewById(R.id.tbn_select_bitmap);btnUpdate = findViewById(R.id.btn_update);/**** @param context   上下文* @param name      数据库名字* @param factory   游标工厂 null* @param version   自定义的数据库版本*/dBhelpUtil = new DBhelpUtil(mContext,DBhelpUtil.DB_NAME,null,DBhelpUtil.DB_VERSION);studentDao = new StudentDao(MainActivity.this,dBhelpUtil);//保存数据事件btnSave.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {//保存数据方法setDataSave();}});// 查询事件btnSelect.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {//查询数据selectDataByID();}});//修改事件btnUpdate.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {updateData();}});//删除事件btnDelete.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {deleteDataById();}});//跟新数据库版本后 增加了字段插入图片btnSaveBitmap.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {try {// 获取文本信息Student student = new Student();student.name = etName.getText().toString();student.sex = etSex.getText().toString();student.age = Integer.valueOf(etAge.getText().toString());student.clazz = etClass.getText().toString();//图片// 获取图片位图Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.logo);//字节数组输出流ByteArrayOutputStream out = new ByteArrayOutputStream();/** 把位图 转换 成字节数组输出流*CompressFormat format,  格式* int quality, 质量 0 - 100* OutputStream stream 输出流*/bitmap.compress(Bitmap.CompressFormat.JPEG,100,out);student.logoHead = out.toByteArray();studentDao.saveBitmap(student);showToast("保存数据成功!");}catch (Exception e){showToast("保存数据失败"+e.getMessage());}}});//查询展示图片btnSelectBitmap.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {selectBitmapMethod();}});}/**保存数据*/public void setDataSave(){try {Student student = new Student();student.name = etName.getText().toString();student.sex = etSex.getText().toString();student.age = Integer.valueOf(etAge.getText().toString());student.clazz = etClass.getText().toString();Long result = studentDao.save(student);if(result != -1){
//                       Toast.makeText(getApplication(),"保存数据成功!返回插入行号是["+result+"]",Toast.LENGTH_SHORT).show();showToast("保存数据成功!返回插入行号是["+result+"]");}else{showToast("保存数据失败result["+result+"]");}}catch ( Exception e){e.printStackTrace();}}/**查询数据*/public void selectDataByID(){Long id = etSelectID.getText().toString().equals("") || etSelectID.getText().toString().equals(null) ? null:Long.valueOf(etSelectID.getText().toString());List<Student> data = studentDao.select(id);if(data.equals(null) || data.size() == 0){textView.setText("没有查到数据!");}else {textView.setText(data.toString());}}/**删除数据*/public  void deleteDataById(){Long id = etDeleteID.getText().toString().equals("") || etDeleteID.getText().toString().equals(null) ? null : Long.valueOf(etDeleteID.getText().toString());int result = studentDao.delete(id);if(result != 0){showToast("删除数据成功!删除了["+result+"]条记录!");}else{showToast("删除数据失败result["+result+"]");}}/**查询展示图片*/public void selectBitmapMethod(){try {Long id = etSelectID.getText().toString().equals("") || etSelectID.getText().toString().equals(null) ? 1:Long.valueOf(etSelectID.getText().toString());Student data = studentDao.selectBitmapById(id);if(data != null){// 把数据显示到页面etName.setText(data.name);etSex.setText(data.sex);etAge.setText(data.age+"");etClass.setText(data.clazz);//有数据再转if(data.logoHead != null){textView.setText(" ");// 把字节数组 转成位图Bitmap bitmap = BitmapFactory.decodeByteArray(data.logoHead,0,data.logoHead.length);imageView.setImageBitmap(bitmap);}else{textView.setText("没有图片数据!");}}else{textView.setText("没有查到数据!");}}catch (Exception e){e.printStackTrace();showToast("查询失败"+e.getMessage());}}/**更新**/public void updateData(){Long id = etDeleteID.getText().toString().equals("") || etDeleteID.getText().toString().equals(null) ? 1 : Long.valueOf(etDeleteID.getText().toString());Student student = new Student();student.name = etName.getText().toString();student.sex = etSex.getText().toString();student.age = Integer.valueOf(etAge.getText().toString());student.clazz = etClass.getText().toString();int result = studentDao.updateById(student,id);if(result != 0){showToast("修改数据成功!修改了["+result+"]条记录!");}else{textView.setText("没有【"+ id +"】这条记录!");showToast("修改数据失败result["+result+"]");}}public void showToast(String msg) {Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();}//异步弹框public void showToastSync(String msg) {Looper.prepare();Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();Looper.loop();}
}

布局 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:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity">
<TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="SQLite 简单应用:"android:textSize="24sp"/><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24sp"android:text="姓名:"/><EditTextandroid:id="@+id/et_name"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="24sp"/></LinearLayout><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24sp"android:text="性别:"/><EditTextandroid:id="@+id/et_sex"android:inputType="text"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="24sp"/></LinearLayout><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24sp"android:text="年龄:"/><EditTextandroid:id="@+id/et_age"android:inputType="number"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="24sp"/></LinearLayout><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="24sp"android:text="班级:"/><EditTextandroid:id="@+id/et_class"android:layout_width="match_parent"android:layout_height="wrap_content"android:textSize="24sp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/tbn_save"android:layout_weight="1"android:layout_width="0dp"android:layout_height="wrap_content"android:text="保存数据"android:textSize="14sp"/><Buttonandroid:id="@+id/btn_save_bitmap"android:layout_weight="2"android:layout_width="0dp"android:layout_height="wrap_content"android:text="更新数据库版本后保存图片"android:textSize="12sp"/></LinearLayout><!-- 查询--><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid:inputType="number"android:id="@+id/et_select_id"android:layout_width="80dp"android:layout_height="wrap_content"android:textSize="24sp"/><Buttonandroid:id="@+id/tbn_select"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="查询数据"android:textSize="12sp"/><Buttonandroid:id="@+id/tbn_select_bitmap"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="根据id查询图片"android:textSize="12sp"/></LinearLayout><!-- 删除--><LinearLayoutandroid:layout_marginLeft="10dp"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid:inputType="number"android:id="@+id/et_delete_id"android:layout_width="80dp"android:layout_height="wrap_content"android:textSize="24sp"/><Buttonandroid:id="@+id/tbn_delete"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="删除数据"android:textSize="14sp"/><Buttonandroid:id="@+id/btn_update"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="根据id修改"android:textSize="12sp"/></LinearLayout><ScrollViewandroid:background="#ccc"android:layout_width="match_parent"android:layout_height="120dp"><!-- 显示查询结果--><TextViewandroid:layout_marginLeft="10dp"android:textColor="#ff00ff00"android:textSize="22sp"android:id="@+id/tv_data"android:layout_width="match_parent"android:layout_height="wrap_content"/></ScrollView><ImageViewandroid:id="@+id/iv_image"android:layout_width="match_parent"android:layout_height="wrap_content"/></LinearLayout>

源码地址:GitCode - 开发者的代码家园

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/227494.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Selenium+Python做web端自动化测试框架与实例详解教程

最近受到万点暴击&#xff0c;由于公司业务出现问题&#xff0c;工作任务没那么繁重&#xff0c;有时间摸索seleniumpython自动化测试&#xff0c;结合网上查到的资料自己编写出适合web自动化测试的框架&#xff0c;由于本人也是刚刚开始学习python&#xff0c;这套自动化框架目…

2023网络安全产业图谱

1. 前言 2023年7月10日&#xff0c;嘶吼安全产业研究院联合国家网络安全产业园区&#xff08;通州园&#xff09;正式发布《嘶吼2023网络安全产业图谱》。 嘶吼安全产业研究院根据当前网络安全发展规划与趋势发布《嘶吼2023网络安全产业图谱》调研&#xff0c;旨在进一步了解…

使用Kafka、Flink、Druid构建实时数据系统架构

1. 背景 对于很多数据团队来说&#xff0c;要满足实时需求并不容易。为什么&#xff1f;因为作流程&#xff08;数据采集、预处理、分析、结果保存&#xff09;涉及大量等待。等待数据发送到 ETL 工具&#xff0c;等待数据批量处理&#xff0c;等待数据加载到数据仓库中&#…

k8s中pod的hostport端口突然无法访问故障处理

故障背景&#xff1a; 租户告知生产环境的sftp突然无法访问了&#xff0c;登录环境查看sftp服务运行都是正常的&#xff0c;访问sftp的hostport端口确实不通。 故障处理过程 既然访问不通那就先给服务做个全面检查&#xff0c;看看哪里出了问题&#xff0c;看下sftp日志&#…

Maven——Maven使用基础

1、安装目录分析 1.1、环境变量MAVEN_HOME 环境变量指向Maven的安装目录&#xff0c;如下图所示&#xff1a; 下面看一下该目录的结构和内容&#xff1a; bin&#xff1a;该目录包含了mvn运行的脚本&#xff0c;这些脚本用来配置Java命令&#xff0c;准备好classpath和相关…

Java —— 泛型

目录 1. 什么是泛型 2. 泛型背景及其语法规则 3. 泛型类的使用 3.1 语法 3.2 示例 3.3 类型推导(Type Inference) 4. 裸类型(Raw Type) 4.1 说明 5. 泛型如何编译的 5.1 擦除机制 5.2 为什么不能实例化泛型类型数组 6. 泛型的上界 6.1 上界语法产生的背景 6.2 语法 6.3 示例 6.…

服务器bash进程占用cpu过多疑似中挖矿病毒记录

发现过程 因为我有使用conky的习惯&#xff0c;也就是在桌面上会显示cpu和内存的占用情况&#xff0c;由于服务器不止我一个人使用&#xff0c;最近发现好几次我同学的账户下的bash进程占用特别多&#xff0c;问了他之后&#xff0c;他也说他几次都是没有使用过bash相关服务&a…

八股文-如何理解Java中的多态

什么是多态&#xff1f; 多态是面向对象编程的一个重要概念&#xff0c;它允许一个对象以不同的形式表现。也就是说&#xff0c;在父类中定义的属性和方法&#xff0c;在子类继承后&#xff0c;可以有不同的数据类型或表现出不同的行为。这可以使得同一个属性或方法&#xff0…

41.0/查询/sql注入安全问题以及解决方式。

41.1. 回顾 1. jdbc&#xff1a;[java database connection] java连接数据库 2. 完成了增删改操作。 [1]加载驱动。Class.forName("com.mysql.cj.jdbc.Driver"); [2]获取连接对象: Connection connDriverManager.getConnection(url,user,pass); url: jdb…

java+python农村集体产权管理系统php+vue

注册、登陆该系统根据操作权限的不同分为管理员和用户两种&#xff0c;新用户在登陆前要进行用户注册&#xff0c;注册完成后方可进行登陆。 本次设计的关键问题处理&#xff0c;主要有如下几点&#xff1a; (1&#xff09;本次开发&#xff0c;采用主流Thinkphp框架进行开发&a…

香港科技大学广州|智能制造学域博士招生宣讲会—华中科技大学专场

时间&#xff1a;2023年12月08日&#xff08;星期五&#xff09;15:00 地点&#xff1a;华中科技大学大学生活动中心A座603 报名链接&#xff1a;https://www.wjx.top/vm/mmukLPC.aspx# 宣讲嘉宾&#xff1a; 胡鹏程 副教授 https://facultyprofiles.hkust-gz.edu.cn/faculty-…

【区块链】产品经理的NFT初探

常见的FT如比特币&#xff08;BTC&#xff09;&#xff0c;以太币&#xff08;ETH&#xff09;等&#xff0c;两个代币之间是完全可替换的。而NFT具有唯一性&#xff0c;不可以互相替换。本文作者对NET的发展现状、相关协议、应用场景等方面进行了分析&#xff0c;一起来看一下…