JDBC에서 물음표 "?"가 포함된 PostgreSQL JSON(B) 연산자를 사용하는 방법
PostgreSQL은 물음표를 사용하는 여러 가지 방법을 제공합니다. 이름으로 다음 JSON과 같은 영리한 ASCII 연산자의 일부 연산자:
- ?: 문자열이 JSON 값의 최상위 키로 존재합니까?
- ?|: 이러한 배열 문자열 중 최상위 키로 존재하는 것이 있습니까?
- ?&: 이 배열 문자열이 최상위 키로 존재합니까?
문제는 공식 PostgreSQL JDBC 드라이버가 이러한 연산자가 포함된 SQL 문자열을 올바르게 구문 분석할 수 없는 것 같습니다. 물음표를 일반 JDBC 바인드 변수로 간주합니다. 다음 코드...
try ( PreparedStatement s = c.prepareStatement("select '{}'::jsonb ?| array['a', 'b']"); ResultSet rs = s.executeQuery()) { ... }
... 예외가 발생합니다.
org.postgresql.util.PSQLException: Für den Parameter 1 wurde kein Wert angegeben. at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:225) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:190) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
이 연산자를 어떻게 사용합니까?
두 가지 해결 방법이 있습니다.
1. 준비된 문 대신 정적 문을 사용합니다.
이것이 가장 간단한 해결 방법이지만 준비된 문의 모든 이점(성능, SQL 주입 보호 등)을 잃게 됩니다. 그러나 다음과 같이 하면 작동합니다.
try ( Statement s = c.createStatement(); ResultSet rs = s.executeQuery("select '{}'::jsonb ?| array['a', 'b']")) { ... }
2. 연산자를 사용하지 마세요. 대신 함수를 사용하세요(참고: 인덱싱은 사용되지 않을 수 있습니다)
연산자는 pg_catalog에 있는 지원되는 함수에 대한 구문 설탕일 뿐입니다. 이러한 함수의 이름을 찾는 방법은 다음과 같습니다.
SELECT oprname, oprcode || '(' || format_type(oprleft, NULL::integer) || ', ' || format_type(oprright, NULL::integer) || ')' AS function FROM pg_operator WHERE oprname = '?|';
위 작업으로 생성되는 결과는 다음과 같습니다.
oprname function ---------------------------------------------------------------------------------- ?| point_vert(point, point) ?| lseg_vertical(-, lseg) ?| line_vertical(-, line) ?| jsonb_exists_any(jsonb, text[]) <p> 따라서 가장 간단한 해결책은 연산자를 사용하는 것이 아니라 해당 함수를 사용하는 것입니다. 🎜></p>
위 내용은 물음표 '?'와 함께 PostgreSQL JSONB 연산자를 사용하는 방법 JDBC에서?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

mysqlviewshavelimitations : 1) 그들은 upportallsqloperations, datamanipulation throughviewswithjoinsorbqueries를 제한하지 않습니다

적절한 usermanagementInmysqliscrucialforenhancingsecurityandensuringfefficientDatabaseOperation.1) USECREATEUSERTOWDDUSERS,@'localHost'or@'%'.

mysqldoes notimposeahardlimitontriggers, butpracticalfactorsdeteirefectiveuse : 1) ServerConfigurationimpactStriggerManagement; 2) 복잡한 트리거 스케일 스케일 사이드로드; 3) argertableSlowtriggerTriggerPerformance; 4) High ConconcercencyCancaUspriggerContention; 5) m

예, It 'safetostoreBlobdatainmysql, butconsidertheStefactors : 1) StoragesPace : BlobScanconSumeSignificantspace, 잠재적으로 증가하는 CostsandSlownperformance

PHP 웹 인터페이스를 통해 MySQL 사용자를 추가하면 MySQLI 확장 기능을 사용할 수 있습니다. 단계는 다음과 같습니다. 1. MySQL 데이터베이스에 연결하고 MySQLI 확장자를 사용하십시오. 2. 사용자를 생성하고 CreateUser 문을 사용하고 Password () 함수를 사용하여 암호를 암호화하십시오. 3. SQL 주입 방지 및 MySQLI_REAL_ESCAPE_STRING () 함수를 사용하여 사용자 입력을 처리하십시오. 4. 새 사용자에게 권한을 할당하고 보조금 명세서를 사용하십시오.

mysql'sblobissuilableforstoringbinarydatawithinareldatabase, whilenosqloptionslikemongodb, redis, and cassandraofferflexible, scalablesolutionsforunstuctureddata.blobissimplerbutcanslowwownperformance를 사용하는 것들보업 betterscal randaysand

TOADDAUSERINMYSQL, 사용 : CreateUser'UserName '@'host'IdentifiedBy'Password '; 여기서'showTodoitseciRely : 1) ChoosetheHostCareLyTocon trolaccess.2) setResourcelimitswithOptionslikemax_queries_per_hour.3) Usestrong, iriquepasswords.4) enforcessl/tlsconnectionswith

toavoidcommonmistakeswithstringdatatypesinmysql, stroundStringTypenuances, chooseTherightType, andManageEncodingAndCollationSettingSefectively.1) usecharforfixed-lengthstrings, varcharvariable-length, andtext/blobforlargerdata.2) setcarcatter


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

드림위버 CS6
시각적 웹 개발 도구

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

WebStorm Mac 버전
유용한 JavaScript 개발 도구