Java ORA-00904: "pass": 无效标识符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16394463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 06:39:55  来源:igfitidea点击:

ORA-00904: "pass": invalid identifier

javanetbeanssqlplus

提问by user2340915

I have a project named 'Online Recruitment System'. There is problem in database connectivity.

我有一个名为“在线招聘系统”的项目。数据库连接有问题。

First i made table 'registration' and 'clogindetails' without using quotes in sqlplus. Then all data used to save properly, but on login I was getting following error:

首先,我制作了表 'registration' 和 'clogindetails' 而没有在 sqlplus 中使用引号。然后所有数据都用于正确保存,但在登录时我收到以下错误:

java.sql.SQLException: ORA-00904: PASSWORD: invalid identifier

java.sql.SQLException: ORA-00904: PASSWORD: invalid identifier

After this I read stackoverflow multiple examples. And I added "double quotes" to the table items in database and kept them in lowercase.

在此之后,我阅读了 stackoverflow 的多个示例。我在数据库中的表项中添加了“双引号”并将它们保持为小写。

Now the data is not even getting saved. I tried to look in 'object browser' in 'data' tab and there was following error:

现在数据甚至没有得到保存。我试图在“数据”选项卡中查看“对象浏览器”,但出现以下错误:

failed to parse SQL query:
ORA-00904: "pass": invalid identifier

As far I know the project is made all right. Only there is problem in making tables.

据我所知,这个项目做得很好。只有制作表格有问题。

Here is code from one of the page which use table 'clogindetails':

这是来自使用表“clogindetails”的页面之一的代码:

   String usrname=getClogid();
   String pass=getCpassword();

   if(usrname!=null && pass!=null && usrname.length()>0 && pass.length()>0)
   {
      ps = con.prepareStatement("select * from clogindetails where logid=? and password=?");
      ps.setString(1,usrname);
      ps.setString(2,pass);
      rs=ps.executeQuery();
      HttpSession session=request.getSession(true);
      if(!rs.next())
      {
         errors.add("invalid", new ActionMessage("errors.invalidusername"));
      }
   }

   rs.close();
   ps.close();
   con.close();
}
catch(Exception e)
{
   e.printStackTrace();
}

if(getClogid()==null || getClogid().length()<1)
{
   errors.add("logid", new ActionMessage("errors.logid.required"));
}

if(getCpassword()==null || getCpassword().length()<1)
{
   errors.add("password", new ActionMessage("errors.password.required"));
}
return errors;

the schema of clogindetails is

clogindetails 的架构是

CREATE TABLE "CLOGINDETAILS"(
   "ADMITID" NUMBER(15,0),
   "NAME" VARCHAR2(25),
   "LOGID" VARCHAR2(10),
   "PASS" VARCHAR2(20)
)

回答by Jayant Jadhav

By looking at user exception error i could say that such type of exceptions are occurred when we are using different column names. for ex: i have created table in database i.e create table tb_login(username varchar(10), password varchar(10));

通过查看用户异常错误,我可以说当我们使用不同的列名时会发生这种类型的异常。例如:我在数据库中创建了表,即创建表 tb_login(username varchar(10), password varchar(10));

and my java code is

我的java代码是

ps=con.prepareStatement("select * from tb_login where username=? and pass=?"); //error bcz pass
This code will produce same exception bcz in my database second column name is password not pass. so check your database schema and java code. or else share your database schema.

ps=con.prepareStatement("select * from tb_login where username=? and pass=?"); //error bcz pass
这段代码将在我的数据库中产生相同的异常 bcz,第二列名称是 password not pass。所以检查你的数据库架构和java代码。或者共享您的数据库架构。

回答by Jayant Jadhav

k now try this

现在试试这个

ps=con.prepareStatement("select * from clogindetails where logid=? and pass=?");

ps=con.prepareStatement("select * from clogindetails where logid=? and pass=?");

rest of the code keep as it is..

其余代码保持原样..

回答by Medet Koilybay

Try to do this one:

尝试这样做:

Change your query

更改您的查询

from: select * from clogindetails where logid=? and password=?

从: select * from clogindetails where logid=? and password=?

to: select * from clogindetails where logid='?' and password='?'

到: select * from clogindetails where logid='?' and password='?'

Point is that when you make queries, you should spot your identifiers with ' ', otherwise it seems like you are comparing some unknown table column's data (variables) with data from existing columns.

要点是,当您进行查询时,您应该使用“ ”找出您的标识符,否则您似乎正在将某些未知表列的数据(变量)与来自现有列的数据进行比较。

ex: select e.full_name from e.employees where e.full_name like '&Medet&'otherwise you'll get an error.

例如:select e.full_name from e.employees where e.full_name like '&Medet&'否则你会得到一个错误。

Hope this will help you!

希望能帮到你!

回答by Talal Qaboos

This error occurs when your column name not as same as you are writing in your query . and avoid to give column names which are Keyword of oracle , Group this cant be your column name or table name.

当您的列名称与您在查询中写入的名称不同时,会发生此错误。并避免给出作为 oracle 关键字的列名,这不能是您的列名或表名。

回答by Dulith De Costa

ORA-00904is common when invalid alias in a select statement is referred.

引用 select 语句中的无效别名时,ORA-00904很常见。

To overcome this error, you need enter a valid column name.

要克服此错误,您需要输入有效的列名

To avoid ORA-00904, column names cannot be a reserved word, and must contain these four criteria to be valid:

为避免ORA-00904,列名不能是保留字,并且必须包含以下四个条件才能有效:

  • begin with a letter
  • be less than or equal to thirty characters
  • consist only of alphanumeric and the special characters ($_#); other characters need double quotation marks around them
  • 以字母开头
  • 少于或等于三十个字符
  • 仅由字母数字和特殊字符 ($_#) 组成;其他字符需要用双引号括起来

For more info you can refer this link.

有关更多信息,您可以参考此链接。

http://www.dba-oracle.com/t_ora_00904_string_invalid_identifier.htm

http://www.dba-oracle.com/t_ora_00904_string_invalid_identifier.htm