0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PrismaでMicrosoftSQLServerに接続する時は特殊文字にご注意(P1013)

Last updated at Posted at 2024-12-19

結論

接続文字列中の特殊文字には、SQLServer用のエスケープ処理をしてあげましょう。
(↓こんな感じ)

sqlserver://hostname:port;user=hoge;password={hoge@(Y?<)N?*1};...

嵌まっていた事象

prismaでAzure SQLServerに接続しようとした際に下記のエラーが発生した。

 P1013: The provided database string is invalid. Error parsing connection string: Conversion error: Invalid JDBC token in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.

日本語訳

P1013: 提供されたデータベース文字列が無効です。接続文字列の解析エラー: 変換エラー: データベースURL内の無効なJDBCトークン。正しい接続文字列の構築方法については、https://www.prisma.io/docs/reference/database-reference/connection-urls のドキュメントを参照してください。場合によっては、特定の文字をエスケープする必要があります。文字列に不正な文字が含まれていないか確認してください。

どうやらprisma接続文字列の特殊文字はエスケープが必要なご様子。

調査

エラーで吐かれたhttps://www.prisma.io/docs/reference/database-reference/connection-urlsに取り敢えずアクセス。

ざっと確認すると下図の様な記載を発見。
prisma.png

どうやらSQLServerの特殊文字をエスケープする場合、特殊文字を含む値を注括弧で囲む必要があるとのことです。

結果

こんな感じで特殊文字をエスケープ処理修正したところ、無事接続出来ました!

sqlserver://hostname:port;user=hoge;password={hoge@(Y?<)N?*1};...

結論

ドキュメントをしっかり読まねば...

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?