首页 > 其他分享 >5.25博客

5.25博客

时间:2024-06-16 20:23:10浏览次数:11  
标签:02 preparedStatement resultSet 博客 record 5.25 sql import

满满一周的课终于结束,奖励自己一杯奶茶吧

学习内容:安卓

package com.example.app_02.utils;
import com.example.app_02.R; import com.example.app_02.database.MySQLConnection; import com.example.app_02.entity.Record; import com.example.app_02.entity.User;
import java.util.ArrayList;
public class RecordDao extends MySQLConnection {     public int insertRecord(Record record) {         int value = 0;         connect();         try {             String sql = "insert into record(starttime, endtime, record) values(?,?,?)";             preparedStatement = connection.prepareStatement(sql);             //将数据插入数据库中             preparedStatement.setString(1, record.getStartTime());             preparedStatement.setString(2, record.getEndTime());             preparedStatement.setString(3, record.getRecord());             value = preparedStatement.executeUpdate();         } catch (Exception e) {             e.printStackTrace();         } finally {             close();         }         return value;     }     public ArrayList<Record> findRecord() {         connect();         ArrayList<Record> arrayList = new ArrayList<>();         try {             //sql语句。我这里是根据我自己的users表的username字段来查询记录             String sql = "select * from record where 1=1";             //获取用于向数据库发送sql语句的preparedStatement             preparedStatement = connection.prepareStatement(sql);             //根据账号进行查询             //执行sql查询语句并返回结果集             resultSet = preparedStatement.executeQuery();             while (resultSet.next()) {                 //.next()表示指针先下一行,若有数据则返回true                 Record record = new Record(resultSet.getString("starttime"), resultSet.getString("endtime"), resultSet.getString("record"));                 arrayList.add(record);             }         } catch (Exception e) {             e.printStackTrace();         } finally {             close();         }         return arrayList;//若传入成功返回账号,失败则为null     } }

标签:02,preparedStatement,resultSet,博客,record,5.25,sql,import
From: https://www.cnblogs.com/zjm921/p/18251183

相关文章

  • 5.28博客
    又是周一,那些杀不死我的还不如直接杀死我学习内容:安卓packagecom.example.app_02.utils;importcom.example.app_02.database.MySQLConnection;importcom.example.app_02.entity.User;importcom.example.app_02.entity.UserInfo;publicclassUserDaoextendsMySQLCo......
  • 5.29博客
    上午计网下午建民老师的课学习内容:安卓packagecom.example.app_02.utils;importcom.example.app_02.database.MySQLConnection;importcom.example.app_02.entity.User;importcom.example.app_02.entity.UserInfo;publicclassUserInfoDaoextendsMySQLConnection{......
  • 5.30博客
    周三:python和工程数学python学习:importrequestsfrombs4importBeautifulSoupasbsimportpandasaspdfrommatplotlibimportpyplotaspltdefget_rank(url):count=0 rank=\[\] headers={    "user-agent":"Mozilla/5.0(WindowsNT10......
  • 5.14博客
    学习内容:安卓<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="wrap_content"......
  • 5.13博客
    看看日历又是周一,本来都起床了感觉尸体有点不舒服,再躺会吧学习内容:安卓<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="......
  • 5.17博客
    排球课比赛快完了,目前为止一场没输过,我感觉这跟我课脱不了关系学习内容:spring-boot注册条件安卓:<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:id="@+id/ll_item"  an......
  • 5.6博客
    过完五一假了该进入学习状态了学习内容:安卓<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent"  android:layout_height="m......
  • 4.30博客
    上午计网下午建民课晚上跑步真是充实学习内容:安卓<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical&qu......
  • 2024年6月16日 18:10,cnblog博客园的第一天!!!
    终于A了P06614迷宫游戏5,原来是动态规划......点击查看代码#include<bits/stdc++.h>#definedebug(a);cout<<#a<<"="<<a<<endl;#definerep(i,a,b)for(inti=a;i<=b;i++)#definepep(i,a,b)for(inti=a;i>=b;i--)usingnamespacestd;......
  • css样式综合案例----博客园首页简单搭建
    1<!DOCTYPEhtml>2<htmllang="en">3<head>4<metacharset="UTF-8">5<title>博客园</title>6<metaname="viewport"content="width=device-width,initial-scal......