暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL jdbc prepared statement 问号?占位符 如何转义

digoal 2020-11-24
1922

作者

digoal

日期

2020-11-24

标签

PostgreSQL , jdbc , prepared statement


背景

PostgreSQL jdbc prepared statement 问号?占位符 如何转义?

例如阿里云pase向量插件, 用于图像识别, 有一个向量计算操作符: <?> 带有问题, 可能被认为是变量占位符.

```

The error may exist in file [/Users/BaoHang/Code/Project/Coding/Java/iotx-ai-business/iotx-ai-business-dal/target/classes/mybatis/postgresql/DataUserFaceMapper.xml]

The error may involve defaultParameterMap

The error occurred while setting parameters

SQL: select id, xxx, xxx, xxx, face_id, xxx <?> ? ::pase as face_confidence, xxx, xxx from xxx where xxx = ? and xxx = ? order by xxx <?> ? ::pase limit 5

Cause: org.postgresql.util.PSQLException: 未设定参数值 5 的内容。

; 未设定参数值 5 的内容。; nested exception is org.postgresql.util.PSQLException: 未设定参数值 5 的内容。
```

用两个连续问号可以转义

https://jdbc.postgresql.org/documentation/head/statement.html

In JDBC, the question mark (?) is the placeholder for the positional parameters of a PreparedStatement. There are, however, a number of PostgreSQL operators that contain a question mark. To keep such question marks in a SQL statement from being interpreted as positional parameters, use two question marks (??) as escape sequence. You can also use this escape sequence in a Statement, but that is not required. Specifically only in a Statement a single (?) can be used as an operator.

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论