小编mri*_*rid的帖子

使用其唯一ID删除ArrayList的对象

我在的功能方面遇到问题ArrayList。我正在尝试通过指定ArrayList的对象来删除它们IDcreateEmployeeMain班上有一个方法:

public void createEmployee(){
    String typeofemployee = sc.nextLine();

    UUID uniqueID = UUID.randomUUID();
    String x = "" + uniqueID;
    System.out.println("The new ID of the " + typeofemployee + " is: " + uniqueID + ".");

    System.out.println("What's the name of the new " + typeofemployee + "?");
    name = sc.nextLine();
    System.out.println("What's the salary of the new " + typeofemployee + "?");
    salary = sc.nextDouble();
    Employee employee = new Employee(x, name, salary);

    switch (typeofemployee) { …
Run Code Online (Sandbox Code Playgroud)

java arraylist

2
推荐指数
2
解决办法
2052
查看次数

Java apache POI 设置元数据

我正在使用 Apache POI 生成 excel 报告。但是 excel 文件的属性清楚地提到我已经使用了Apache POI. 我想在这里提到我的软件名称

在此处输入图片说明

这是我当前的代码,我正在尝试设置自定义属性,但它不起作用。

 XSSFWorkbook xlsxSetMetadata = new XSSFWorkbook();
 xlsxSetMetadata.createSheet("Test sheet");
 POIXMLProperties props = xlsxSetMetadata.getProperties();

 POIXMLProperties.CoreProperties coreProp=props.getCoreProperties();
 coreProp.setCreator("---------------");
 coreProp.setDescription("Report");
 coreProp.setKeywords("Report ");
 coreProp.setTitle("... Report");

 POIXMLProperties.ExtendedProperties extProp=props.getExtendedProperties();
 extProp.getUnderlyingProperties().setCompany("XYX company");
 extProp.getUnderlyingProperties().setTemplate("XSSF");

 POIXMLProperties.CustomProperties custProp = props.getCustomProperties();
 custProp.addProperty("Author", "..........");
 custProp.addProperty("Program name", "MY_SOFTWARE_NAME_HERE");

 String fname = "file_name.xlsx";
 FileOutputStream out = new FileOutputStream(fname);
 xlsxSetMetadata.write(out);
 out.close();
Run Code Online (Sandbox Code Playgroud)

如何将program name属性更改为我的程序名称?

java excel apache-poi

2
推荐指数
1
解决办法
725
查看次数

选择不同行中具有匹配条件的记录

假设我有一个SQL表 table1

+--------------------------+
| id | person |   eats     |
+----+--------+------------+
|  1 |   1    |   apple    |
|  2 |   3    |  banana    |    
|  3 |   2    |  orange    |
|  4 |   1    | strawberry |
|  5 |   2    |   grapes   |
|  6 |   4    |   apple    |
+----+--------+------------+
Run Code Online (Sandbox Code Playgroud)

我希望得到所有吃饭的人apple并说出来strawberry.

我试过了

select person 
from table1
where eats in( 'apple', 'strawberry' )
Run Code Online (Sandbox Code Playgroud)

但是这个查询返回1, 1, 4,我猜是因为它正在检查apple并且strawberry单独进行.

怎样才能让所有吃过的 …

mysql sql

1
推荐指数
1
解决办法
82
查看次数

节点JS mysql查询第二次执行时给出错误

我正在尝试使用express在节点中制作REST api。当我第一次在浏览器中打开URL时,它运行良好,并为我提供了正确的输出。但是,当我第二次点击api网址时,应用程序崩溃并显示以下错误:

events.js:141 throw er; //未处理的“错误”事件^

错误:调用退出后无法排队握手。

这是我正在使用的代码:

var express = require('express');
var mysql = require('mysql');

var app = express();
var connection = mysql.createConnection({
  host: 'localhost',
  user: 'USER_NAME',
  password: 'PASSWORD'
});

app.use(express.static(__dirname + '/public'));
var port = 3333;

app.get('/api/users/:user_id', function(req, res){
    var lead_id = req.params.user_id;

    connection.connect();

    connection.query('use DB_NAME;', function (err) {
        if(err) throw err;

        connection.query('select * from users where user_id = ' + user_id, function (err, rows) {
            if(err) throw err;

            res.json(rows);
            connection.end();
        });
    });
});

app.listen(port);
console.log("The app is …
Run Code Online (Sandbox Code Playgroud)

javascript mysql node.js express node-mysql

1
推荐指数
1
解决办法
779
查看次数

JavaScript关联数组表现奇怪

我有两个对象.当我将这些作为键传递给关联数组并赋值时,所有值都存储错误(最后一个除外).

谁能告诉我我做错了什么?

var usrMrid = {name: "mrid"};
var usrXYZZ = {name: "xyzz"};

var comm = {};

comm[usrMrid] = "ONE";
comm[usrXYZZ] = "TWO";

console.log("usrMrid: " + comm[usrMrid]); // this gives TWO, when it should give ONE
console.log("usrXYZZ: " + comm[usrXYZZ]); // this works fine
Run Code Online (Sandbox Code Playgroud)

javascript arrays associative-array

1
推荐指数
1
解决办法
55
查看次数

C# WinForms 尝试使用计时器更新 UI,但不会降低性能

所以目前我有一个有 2 个进程的应用程序。一个进程正在执行 ping 操作,而 ping 进程则将结果写入数组。

另一个过程是使用计时器每秒更新 UI。更准确地说,更新的是一个 mschart。

这就是我设置计时器的方式:

readonly System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
myTimer.Interval = 1000;
myTimer.Tick += WriteFunction;
Run Code Online (Sandbox Code Playgroud)

现在,这是我每秒调用的用于刷新 UI/实际图表的方法:

 private void WriteFunction(object objectInfo, EventArgs e)
        {
            foreach (NetPinger.source.AddGraph b in graphList)
            {
                b.fileRead();
            }
        }
Run Code Online (Sandbox Code Playgroud)

用于更新图表的方法位于另一个类中,如下所示:

    public void fileRead()
    {
        double unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

        chart_holder.Series[0].Points.Clear();

        for (double i = unixTimestamp; unixTimestamp - graphSizing < i; i--)
        {
            bool exists;
            try
            {
                exists = Array.Exists(file, element => element.XValue == i);
                exists = …
Run Code Online (Sandbox Code Playgroud)

c# multithreading timer mschart winforms

1
推荐指数
1
解决办法
2479
查看次数

C# 在运行时提升程序

我有一个 C# 程序,我希望其中的某些功能需要管理员密码。为了解决这个问题,我启动了应用程序的另一个实例作为提升的进程,并向其传递命令行参数,以便该进程知道它必须执行什么任务。

Process proc = new Process();
proc.StartInfo.Arguments = "PARAMETERS HERE");
proc.StartInfo.FileName = Application.ExecutablePath;
proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";
proc.Start();
Run Code Online (Sandbox Code Playgroud)

这工作正常,但我有一个小问题。我刚刚注意到启动新进程时弹出的 UAC 提示符不仅显示应用程序名称和路径,还显示传递给它的命令行参数。这样,用户可以看到正在传递的参数,并直接从run命令或传递参数command prompt

有什么办法可以防止这种情况吗?或者提升正在运行的程序的更好方法?

c# uac winforms elevated-privileges

0
推荐指数
1
解决办法
1069
查看次数

如何在控制器的方法之间传递变量

我只是想在同一个Laravel控制器中的一种方法之间传递一个变量到另一个方法。我花了几个小时试图弄清楚这一点,但没有运气。我相信这很简单。在其他地方也有类似的答案,但我无法使它们起作用,因此想使其变得非常简单,以便我能够理解。

在下面的代码中,我只想添加输出$ variable(在本例中为数字1)。

例如,假设我在控制器中具有以下方法。

public function index()
{
$variable = 1;
}

public function show()
{
dd($variable);
}
Run Code Online (Sandbox Code Playgroud)

我只希望show函数以dd函数的形式输出dd输出1。谁能帮我一下。正如我所说,我敢肯定这很容易,只是想不通。

php laravel

-1
推荐指数
1
解决办法
107
查看次数