问题描述
这就是问题所在。我用Java抓取了一些数据,最终我将该Java放入了postgres数据库。当我运行Java程序时,出现错误ERROR:关系表名不存在,但是当我亲自在PGAdmin III中编写相同的查询时,它可以正常工作。我用Google搜索了它,但这并不是大多数人都遇到的大写字母。这是屏幕截图:
So here is the problem. I am scraping some data with java and eventually i place that java into postgres database. When i run Java program, i get error ERROR: relation "table name" does not exist but when i personally write that same query in PGAdmin III, it works fine. I googled it and it's not about caps letters that most people have problems with. Here is a screenshot:
推荐答案
我首先想到的是您在对值使用双引号,但是随后我再次查看并意识到您正在使用字符串连接来组装查询
My first thought was that you were using double quotes for values, but then I looked again and realized you were assembling a query using string concatenation.
不要这样做。除了使这些问题无法调试之外,您还可以进行sql注入。
DON'T DO THAT. In addition to making these problems impossible to debug you open yourself up to sql injection.
在调试类似的东西时,您应该首先移植以使用占位符语法(PostgreSQL的JDBC驱动程序支持该语法),然后,如果不起作用,则发布服务器日志。
In debugging something like this, you should first port to use placeholder syntax (which PostgreSQL's JDBC driver supports) and then, if that doesn't work, then post the server logs.
这篇关于错误:不存在关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!