使用 JDBC 连接到 postgres 时是否可以指定架构? [英] Is it possible to specify the schema when connecting to postgres with JDBC?

查看:25
本文介绍了使用 JDBC 连接到 postgres 时是否可以指定架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能吗?我可以在连接 URL 上指定它吗?怎么做?

Is it possible? Can i specify it on the connection URL? How to do that?

推荐答案

我知道这已经得到了回答,但我在尝试指定要用于 liquibase 命令行的架构时遇到了同样的问题.

I know this was answered already, but I just ran into the same issue trying to specify the schema to use for the liquibase command line.

更新从 JDBC v9.4 开始,您可以使用新的currentSchema 参数如下:

Update As of JDBC v9.4 you can specify the url with the new currentSchema parameter like so:

jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema

基于较早的补丁出现:

http://web.archive.org/web/20141025044151/http://postgresql.1045698.n5.nabble.com/Patch-to-allow-setting-schema-search-path-in-the-connectionURL-td2174512.html

建议的网址是这样的:

jdbc:postgresql://localhost:5432/mydatabase?searchpath=myschema

这篇关于使用 JDBC 连接到 postgres 时是否可以指定架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆