小编use*_*902的帖子

Java不安全操作

编译一小段java代码时,我得到了一个不安全操作的编译说明.我基本上只是希望有一个如何改变我的数据结构以保证其安全的概念.

这个概念:我需要根据它们的长度将输入的字符串组织成桶,这可能是任意的(尽管少于80个字符).

代码:

Map<Integer, List> buckets = new HashMap<Integer, List>();
            if(!buckets.containsKey(length))
            {
                buckets.put(length,new Vector<wordValues>());
            }
            //Now add the temp to the bucket
            buckets.get(length).add(new wordValues(temp));
Run Code Online (Sandbox Code Playgroud)

然后我将字符串添加到与其大小相对应的列表中.

什么是更好的方法来做到这一点?

java maps unsafe vector

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

perl的数据库句柄总是未定义的

我在使用perl工作时获得简单的DBI连接时遇到问题.

我放置一个地方检查器来查看数据库句柄是否未定义,并且它总是未定义.有任何明显的错误吗?我确信我输入的信息是正确的,因为我在PHP脚本中使用它.

#!/usr/bin/perl -w
use warnings;
print "Content-Type: text/html\n\n";

use DBI;

# Connecting to the database
# Replace DATABASENAME with the name of the database,
# HOSTNAME with the hostname/ip address of the MySQL server.
$drh = DBI->install_driver("mysql");
$dsn =   "DBI:mysql:database=db_name;host=host_name";
$dbh = DBI->connect($dsn,"username","password");
if(defined $dbh)
{
    print "Yes<br />";
}
else
{
    print "No<br />";
 }

 # Select the data and display to the browser

   $sth = $dbh->prepare("SELECT * FROM customer");
   $sth->execute();
   while (my $ref = $sth->fetchrow_hashref()) {
   print …
Run Code Online (Sandbox Code Playgroud)

perl cgi dbi

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

Perl获取时没有执行错误 - 执行结束时

我当前的perl代码正在运行数据库查询的所有行,然后抛出一个

DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at ./recieveTxn.cgi 
line 168.
Run Code Online (Sandbox Code Playgroud)

在末尾.它几乎就像有些东西没有告诉循环在行的末尾停止,但我已经像其他人一样写了它.

例如:查询会拉高

shortcode1
shortcode2
shortcode3
然后在这里抛出错误

$sql = "
    SELECT
        aPI.folder AS aPIfolder, 
        aPI.rowNum AS aPIrowNum,
        hasInput,
        evalCode
    FROM
        aPersonalItems as aPI
    LEFT JOIN 
        pItems_special_inputs as SI 
    ON
        aPI.folder = SI.folder AND
        aPI.rowNum = SI.rowNum
    WHERE
        hasInput=1 AND
        aPI.folder='$FORM{'folder'}'
    ORDER BY
        aPI.rowNum
";

$sth = $dbh->prepare( $sql );
$sth->execute();

my ($shortcoderow, $row);
my $shortcodeSQL = "
    SELECT 
        * 
    FROM
        pItemsShortCodes 
    WHERE
        folder='$FORM{'folder'}' 
    ORDER BY
        rowNum
";
my $shortcodeSTH = …
Run Code Online (Sandbox Code Playgroud)

mysql perl cgi

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

标签 统计

cgi ×2

perl ×2

dbi ×1

java ×1

maps ×1

mysql ×1

unsafe ×1

vector ×1