会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132990个问题
Python 全系列/第一阶段:Python入门/编程基本概念 28518楼
Python 全系列/第一阶段:Python入门/编程基本概念 28519楼
Python 全系列/第二十三阶段:人工智能基础_机器学习理论和实战(旧)/SVM支持向量机算法 28520楼

老师,那个数据库当中

/**
* 增加操作:使用循环和随机数技巧,增加1000个数据。要求积分在0-200
* 注册时间均匀分布在2018年各个月份。从26个字母中随机取3个字母作为昵称,
* 昵称不能一样。ID自增。
* @return
*/

增加1000个数据时的操作,

@Override
public int insertuserthing(userthing user) {
    //id,可以创建一个数组保存1004-2003的数组,在循环读取
    int []user_id=new int[1000];
    for(int i=0;i<1000;i++){
        user_id[i]=i+1004;
    }
    // 昵称,可以使用String类型数组,保存1000昵称数据,然后进行循环读取
    String[]user_name=new String[1001];
    outer: for (int i = 0;;i++) {// 可能会重复,不确定啥时候结束,不设置结束条件
        char[] result = new char[3];
        int d=new Random().nextInt(25);
        for (int k = 0; k < 3; k++) {
            int letter = 97 + d;
            result[k] = (char) letter;
        }
        String temp = String.valueOf(result);
        // 随机产生三个字母
        for (int j = 0; j < i; j++) {
            if (user_name[j] == temp) {
                continue outer;
            }
        }
        user_name[i] = temp;
        if (user_name[999]!=null) {
            break;
        }
    }
    // 注册时间,年2018,其他随机

    String[] register_time = new String[1000];
    for (int i = 0; i < 1000; i++) {
        register_time[i]= String.valueOf(randomDate("2018-01-01","2018-12-31"));
    }
    // 积分,用随机数获取
    int m=new Random().nextInt(200);
    int[] integral_score = new int[1000];
    for (int i = 0; i < 1000; i++) {
        integral_score[i] = m;
    }
    // 性别,随机二者选一个
    int n=new Random().nextInt(2);
    String[] sex1 = { "男", "女" };
    String[] sex = new String[1000];
    for (int i = 0; i < 1000; i++) {
        sex[i] = sex1[n];
    }
    String sql="insert into userthing values(?,?,?,?,?)";
    Object[] param=new Object[]{user.getUser_id(),user.getUser_name(),user.getRegister_time(),user.getIntegral_score(),user.getSex()};
    return this.executeUpdate(sql,param);
}

 String sql="insert into userthing values(?,?,?,?,?)";
    Object[] param=new Object[]{user.getUser_id(),user.getUser_name(),user.getRegister_time(),user.getIntegral_score(),user.getSex()};
    return this.executeUpdate(sql,param);

这个怎么写?

我插入的数据总是不成功

jdbcDomo3.rar


JAVA 全系列/第三阶段:数据库编程/JDBC技术(旧) 28521楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 28522楼
Python 全系列/第一阶段:Python入门/面向对象 28525楼

#引入模块

import os                       #系统资源控制

import base64                   #文件加密

from tkinter import *           #写GUI

from secrets import token_bytes #生成密匙 


#全局

file_path = ''


#主界面类

class MyGui(Frame):

    def __init__(self,master= None):

        super().__init__(master)

        self.master = master #依赖窗口

        self.pack() #展示

        self.GreateWidget() #创建组件

    def GreateWidget(self):

        global file_path

        self.label01 = Label(self,text='文件路径')

        self.label01.grid(row = 0 ,column = 2)

        

        entry_tmp = StringVar()

        self.entry01 = Entry(self,textvariable = entry_tmp)

        self.entry01.grid(row = 1, column = 2)

        file_path = entry_tmp.get()


        self.button_encryed = Button(self,text= "加密" ,command = Encpryed_file)

        self.button_encryed.grid(row= 2,column = 1)


        self.button_dencryed = Button(self,text = '解密')

        self.button_dencryed.grid(row= 2,column = 2)


        self.button_exit = Button(self,text = '退出',command= self.master.destroy)

        self.button_exit.grid(row= 2,column = 3)


    #错误展示

    def error_display():

        pass

#获得密匙

def GetKeyWordPass():

    pass


#加密部分       

def Encpryed_file():

    print(file_path)


def decryption_file():

    pass



#主函数

def main():

    my_windos = Tk()

    my_windos.title('xxxx小软件')

    my_windos.geometry("250x100+200+100")

    app = MyGui(my_windos)

    my_windos.mainloop()


if __name__ == "__main__":

    main()


老师为什么我读不出entry_tmp变量里面的数据的

我次次读都是空的

图片.png

就是现实不出来


Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 28526楼
JAVA 全系列/第九阶段:权限控制与安全认证/Shiro(旧) 28527楼
JAVA 全系列/第六阶段:项目管理与SSM框架/SpringMVC 28528楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637