德比嵌入数据库奇怪的行为,sqlsyntaxerrorexception

发布于 2025-01-24 20:15:50 字数 1649 浏览 4 评论 0 原文

我在一个Java项目中有一个嵌入式数据库,其中包含两个列“ tool_id”(int)和“ tool_image”(blob)的table tools_images。 我尝试通过以下代码获得斑点:

rs = stmt.executeQuery("SELECT * FROM 'TOOLS_IMAGES' WHERE 'TOOL_id' = " + id);

程序trys以这种方式获得15个不同的图像。当我运行程序时,有时会设法获得一张图像,有时甚至有时甚至六个图像,但在某一时刻,它总是在例外抛出。在那之后,它会给以下每个图像提供此例外:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "\'TOOLS_IMAGES\'" at line 1, column 15.
Caused by: ERROR 42X01: Syntax error: Encountered "\'TOOLS_IMAGES\'" at line 1, column 15.

为什么我在SQL查询中使用使徒?我已经在没有它们的情况下尝试过了,但是在这里SQL将查询中的所有下尺寸转换为大写,并抱怨后来找不到该列-.-找不到该列。 看起来像这样:

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_id = " + id);

编辑

java.sql.SQLSyntaxErrorException: Column 'TOOL_ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'TOOL_ID' is not a column in the target table.
Caused by: ERROR 42X04: Column 'TOOL_ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'TOOL_ID' is not a column in the target table.

: 这是我用来创建表的脚本

create table TOOLS_IMAGES
(
    "TOOL_id"   INTEGER not null
        constraint TOOLS_IMAGES_PK
            primary key,
    "TOOL_mask" BLOB,
    "TOOL_img"  BLOB
);

I've got an embedded database in a Java project with a table TOOLS_IMAGES with two columns "TOOL_id" (int) and "TOOL_image" (blob).
I try to get the blob with following code:

rs = stmt.executeQuery("SELECT * FROM 'TOOLS_IMAGES' WHERE 'TOOL_id' = " + id);

The program trys to get like 15 different images at this way one after another. When I run the program it sometimes manages to get one image, sometimes two, sometimes even six, but at one point it always throws following exception. And after that one fail, it throws this exception for every following image:

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "\'TOOLS_IMAGES\'" at line 1, column 15.
Caused by: ERROR 42X01: Syntax error: Encountered "\'TOOLS_IMAGES\'" at line 1, column 15.

Why do I use apostophes in the SQL query? I already tried it without them, but here sql converts all my lowercases in the query to uppercases and complains afterwars that it can't find that column -.-
Looks like this:

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_id = " + id);

and

java.sql.SQLSyntaxErrorException: Column 'TOOL_ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'TOOL_ID' is not a column in the target table.
Caused by: ERROR 42X04: Column 'TOOL_ID' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'TOOL_ID' is not a column in the target table.

Edit:
Here's the script, which I used to create the table

create table TOOLS_IMAGES
(
    "TOOL_id"   INTEGER not null
        constraint TOOLS_IMAGES_PK
            primary key,
    "TOOL_mask" BLOB,
    "TOOL_img"  BLOB
);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴梦长久 2025-01-31 20:15:50

尝试使用:

ResultSet rs = stm.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE \"TOOL_id\" = " + 1);

如果您说:

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_id = " + id);

它将由德比(Derby)进行处理:

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_ID = " + id);

更多

信息访问

Try to use:

ResultSet rs = stm.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE \"TOOL_id\" = " + 1);

If you put:

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_id = " + id);

It will be processed by Derby like :

rs = stmt.executeQuery("SELECT * FROM TOOLS_IMAGES WHERE TOOL_ID = " + id);

which are not the same

For more info visit

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文