我使用JDBC访问数据库,基本上是通过调用一个字符串来查询。
这是我的桌子book_table
| title | book no. | author_first | author_last |
The cat, 0, Tim, Joe
The dog, 1, John, Soe
The mouse, 2, Josh, Moe下面是我正在查询的SQL语句:
"select title from book_table where author_first like '%tim%' and author_last like '%joe%'";我一直在Java:ORA-00904: "author_last": invalid identifier"中获得错误异常
知道我做错了什么吗?
发布于 2016-10-18 05:01:51
您很可能在为book_table创建DDL时使用了双引号。
从错误中看,这意味着没有像author_first这样的列。
数据库中使用的名称应该工作得很好,如果不使用双引号,大写和小写很可能会被忽略。
create table book_table(title varchar2(100));
create table BOOK_TABLE(TITLE varchar2(100));在这两种情况下
select * from book_table where title like '%mytitle%'; 应该工作得很好。
但是,如果使用双引号,则在执行sql操作时必须使用确切的情况。
create table "BOOK_TABLE"("Title" varchar2(100));在这种情况下
select * from book_table where title like '%mytitle%'不起作用
你必须利用
select * from book_table where "Title" like '%mytitle%';我建议放弃这个表,重新创建没有双引号的表,看看这是否解决了问题。
https://stackoverflow.com/questions/40099567
复制相似问题