【问题标题】:Exception in thread "main" java.lang.NullPointerException as well as java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist线程“主”java.lang.NullPointerException 以及 java.sql.SQLSyntaxErrorException 中的异常:ORA-00942:表或视图不存在
【发布时间】:2013-12-30 18:31:56
【问题描述】:

我正在使用 oracle 10g 和 Java。我正在尝试从一个数据库中检索行并尝试将其数据更新/插入到其他表中。 它在线程“main”java.lang.NullPointerExceptionjava.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist within my results.

for (int i = 0; i < edu_info2.length; i++) {
    if (url.matches("(.*)" + edu_info2[i] + "(.*)")) {
        count[0]++;
    }
    // if(title.matches("(.*)"+edu_info2[i]+"(.*)")){
    // count[0]++;
    // }
    if (k.matches("(.*)" + edu_info2[i] + "(.*)")) {
        count[0]++;
    }
    if (des.matches("(.*)" + edu_info2[i] + "(.*)")) {
        count[0]++;
    }
}

这里我在匹配语句中遇到空指针异常。

while(rs.next()) {
        url = (rs.getString("url")).toLowerCase();
        if(!rs.wasNull()) {
            t = rs.getNString("title");
            System.out.println(t);
        }
        k = rs.getString("keyword");
        des = rs.getString("des");

System.out.println(t) 正在显示结果以及异常

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist.

【问题讨论】:

标签: java oracle


【解决方案1】:

可能的原因包括:

You are talking to the wrong database server.
You are talking to the wrong database.
You've misspelled the table or view name.
Someone has changed the table name or view.
Someone has deleted the table name or view.
Due to some configuration issue, application bug or whatever, the server, database, table or whatever name that you are using is different to what you think it is.

总之……名字错了。

【讨论】:

  • 但 System.out.println(t) 中的一切都是正确的 bcz;它是从数据库中打印数据
【解决方案2】:

我没有足够的声望来添加评论,所以我必须回复...

这个错误 (NullPointerException) 不是一个糟糕的错误,因为它可以准确地告诉您它在哪里遇到错误以及什么等于 null。我建议仔细检查您的代码以找出您可能缺少的确切内容,如果不能,请使用控制台打印出您拥有的每个变量。一旦你找到一个写着null的输出,你就知道你找到了你的受害者,你可以通过过滤你的代码来找出为什么它等于null。

【讨论】:

  • if (k.matches("(.*)" + edu_info2[i] + "(.*)")) 这给出了空指针异常
猜你喜欢
  • 2016-08-23
  • 2016-09-17
  • 2019-01-22
  • 1970-01-01
  • 2015-11-09
  • 2011-12-10
  • 2015-01-30
相关资源
最近更新 更多