connection-string 相关问题

包含连接服务所需信息的字符串,通常是数据库。

错误:无法在只读事务中执行 CREATE TABLE - Jasper 报告

我在贾斯珀面临这个恼人的问题。我创建了一个基于 PostgreSQL 函数的报告。当我观看预览时,我对结果没有任何问题。然而,当我发布

回答 2 投票 0

如何在SQLAlchemy的`create_engine`中使用`charset`和`encoding`(创建pandas数据框)?

我对 SQLAlchemy 中字符集和编码的工作方式感到非常困惑。我理解(并且已经阅读)字符集和编码之间的区别,并且我对 enco 的历史有很好的了解...

回答 5 投票 0

为什么我的环境变量没有覆盖appsettings.json

我有一个使用 ASP.NET Core Web API 和 mongodb 的应用程序,它们都是由 docker-compose 容器化的,我不知道为什么我的 appsettings 没有被覆盖。 这是我的 appsettings.j...

回答 1 投票 0

尝试部署:org.postgresql.util.PSQLException:连接尝试失败

在 render.com 上拥有帐户,我创建了 postgres 数据库并获取了用户名、密码和外部链接(主机,端口为 5432),所以我按照此处的建议指定了网址(jdbc:postgresql:// 在 render.com 上拥有帐户,我创建了 postgres 数据库并获取了用户名、密码和外部链接(主机,端口为 5432),所以我按照建议指定了 url here (jdbc:postgresql://<host>:<port>/<dbname>?user=<username>&password=<password>)。 application.properties: #spring.datasource.url=jdbc:postgresql://localhost:5432/webdev_simplified spring.datasource.url=jdbc:postgresql://@dpg-cligukdkt82s73c4s830-a.oregon-postgres.render.com:5432/webdev_simplified?user=webdev_simplified_user&password=redacted #spring.datasource.username=postgres #spring.datasource.username=webdev_simplified_user #spring.datasource.password=postgres #spring.datasource.password=c8Ca0ZTgSkokADeeEeoIM9WFPPjPLXHx spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.format_sql=true logging.level.org.hibernate.SQL=DEBUG 我使用了他们所说的 external url 从我本地的 ubuntu 连接到它。但是当运行mvn clean package时,我得到: . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v3.2.0) 2023-11-28T21:11:52.164+01:00 INFO 16808 --- [ main] com.example.j2.J2ApplicationTests : Starting J2ApplicationTests using Java 17.0.2 with PID 16808 (started by shepherd in /home/shepherd/Desktop/java/j2) 2023-11-28T21:11:52.166+01:00 INFO 16808 --- [ main] com.example.j2.J2ApplicationTests : No active profile set, falling back to 1 default profile: "default" 2023-11-28T21:11:53.139+01:00 INFO 16808 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2023-11-28T21:11:53.220+01:00 INFO 16808 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 69 ms. Found 1 JPA repository interface. 2023-11-28T21:11:53.793+01:00 INFO 16808 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2023-11-28T21:11:54.843+01:00 ERROR 16808 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225) ~[postgresql-42.2.15.jar:42.2.15] ... 我确信我的主机是正确的,因为我只是复制/粘贴它(就像 psasword 一样)。那么会出现什么问题呢? 这是源代码: https://github.com/shepherd123456/springapp_with_postgres PS:错误很长,所以我只选择了我认为可能重要的部分: ... Caused by: java.net.UnknownHostException: @dpg-cligukdkt82s73c4s830-a.oregon-postgres.render.com at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:567) ~[na:na] at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[na:na] at java.base/java.net.Socket.connect(Socket.java:633) ~[na:na] at org.postgresql.core.PGStream.createSocket(PGStream.java:231) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.core.PGStream.<init>(PGStream.java:95) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:98) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213) ~[postgresql-42.2.15.jar:42.2.15] ... 120 common frames omitted 2023-11-29T11:11:33.472+01:00 INFO 4223 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2023-11-29T11:11:33.572+01:00 INFO 4223 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.3.1.Final 2023-11-29T11:11:33.639+01:00 INFO 4223 --- [ main] o.h.c.internal.RegionFactoryInitiator : HHH000026: Second-level cache disabled 2023-11-29T11:11:33.981+01:00 INFO 4223 --- [ main] o.s.o.j.p.SpringPersistenceUnitInfo : No LoadTimeWeaver setup: ignoring JPA class transformer 2023-11-29T11:11:34.028+01:00 INFO 4223 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2023-11-29T11:11:35.030+01:00 ERROR 4223 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-42.2.15.jar:42.2.15] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225) ~[postgresql-42.2.15.jar:42.2.15] ... ... at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495) ~[surefire-booter-3.1.2.jar:3.1.2] 2023-11-29T11:11:35.045+01:00 ERROR 4223 --- [ main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect') 2023-11-29T11:11:35.047+01:00 WARN 4223 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect') 2023-11-29T11:11:35.067+01:00 INFO 4223 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger : Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2023-11-29T11:11:35.092+01:00 ERROR 4223 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect') at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1775) ~[spring-beans-6.1.1.jar:6.1.1] ... ... [INFO] [INFO] Results: [INFO] [ERROR] Errors: [ERROR] J2ApplicationTests.contextLoads » IllegalState Failed to load ApplicationContext for [WebMergedContextConfiguration@62ea8931 testClass = com.example.j2.J2ApplicationTests, locations = [], classes = [com.example.j2.J2Application], contextInitializerClasses = [], activeProfiles = [], propertySourceDescriptors = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@74ea2410, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@248e319b, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@548d708a, org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@353352b6, org.springframework.boot.test.context.SpringBootTestAnnotation@85af5aae], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null] [INFO] [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE ... 所以这就是说UnknownHostException: Caused by: java.net.UnknownHostException: @dpg-cligukdkt82s73c4s830-a.oregon-postgres.render.com 但话又说回来,主机是从站点复制/粘贴的。您可以在 External Database Url 相同的网址中看到附加的图像(以 @ 开头)。我将再次从我的 render.com 帐户复制未修改的内容(有 postgres 而不是 postgresql,并且用户和密码在 url 之前指定,而不是作为上面链接建议的查询参数): postgres://webdev_simplified_user:c8Ca0ZTgSkokADeeEeoIM9WFPPjPLXHx@dpg-cligukdkt82s73c4s830-a.oregon-postgres.render.com/webdev_simplified 根据 DNS 错误消息并尝试我自己的简单 jdbc 示例,您需要将主机名中的 @ 去掉。就像您不能在主机名前面指定用户名和密码一样,您也不能在其前面放置一个裸露的@。它被解释为主机名中的文字字符。 可惜,并非所有驱动程序都支持格式化 db URL 的所有方式。

回答 1 投票 0

如何在 aws emr 上设置 Presto 服务器并允许用户通过连接字符串访问数据

我是 Presto 和 Hive 的新手。我正在开发一个项目,我必须使用 aws 并设置一个同时运行 presto 和 hive 的 emr 集群。我能够做到这一点,并且我可以从 cli 访问 hive,我可以

回答 1 投票 0

通过套接字连接 MySQL 的 Prisma URL 字符串

根据 Prisma 文档,使用套接字的连接字符串的模板是: mysql://USER:POST@localhost/database?socket=/var/run/mysql/ 基于此,我创建了以下内容,更改...

回答 1 投票 0

从 VS Code 部署后,MYSQL 数据库在 Azure 计时器触发函数中出错,即使它在本地工作正常

我在 Visual Studio 代码中通过 C# 使用 MYSQL 数据库连接器创建了一个 Azure 计时器触发器函数。它在我的开发 PC 上测试良好,但在 Azure 上成功部署后出错。 一个...

回答 1 投票 0

使用加密的自定义连接字符串生成 Telerik 报告而不使用 Web.Config 连接字符串

我正在开发一个需要生成 Telerik 报告的项目,并且我正在尝试实现一个解决方案,其中 Telerik 报告中使用的连接字符串是加密的并且不依赖于

回答 1 投票 0

将模型类型ViewModel添加到DbContext时出错

当我想使用 EF Core Identity 搭建控制器时,出现如下错误 错误 运行所选代码生成器时出错:“无法添加模型类型” '电气.模型.视图...

回答 1 投票 0

TableAdapter Provider 使用 Microsoft.Data.SqlClient,无论 ProviderName 设置如何

我正在尝试使用 Web.config 中添加的连接字符串创建一个新的 TableAdapter,并尽量减少与现有库不兼容的可能性,我希望我的提供程序是 System.Data。

回答 1 投票 0

我在 .NET Core 6.0 中有一个最小的 API,在存储库模式中使用 ADO.NET

我正在使用一个最小的 API 和一个服务,该服务调用 .NET Core 6.0 中的存储库。我希望能够将连接字符串传递到我的存储库。 这是我的项目的树: 这个想法是

回答 1 投票 0

打开mysql连接在net core中抛出异常

我试图打开一个刚刚关闭的mysql连接,这引发了一个完全误导性的异常:“给定的键不存在于字典中”我的代码可以总结如下: 尝试 { ...

回答 1 投票 0

如何使用构建器(WebApplication.CreateBuilder)使我的connectionString可供我的DataAccess类使用

我在 appsettings.json 文件中设置了连接字符串,我可以使用 Console.WriteLine 在 Main 中看到它,所以我知道我正在正确地将其获取到 program.cs。 var builder = WebApplication.

回答 1 投票 0

如何获取免费的mongoDB连接字符串?

连接到服务器时,我们需要 mongoDB 连接字符串,该字符串之前是免费的,现在是付费的。有没有其他方法可以免费获得相同的东西 获取免费连接字符串的过程

回答 2 投票 0

用户控件中的连接字符串不起作用

我正在尝试(学习)在Winforms中制作UserControl。这是我的app.config 我正在尝试(学习)在 Winforms 中制作 UserControl。这是我的 app.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="LoginTestDB_cf" connectionString="Data Source=.\SqlExpress;Initial Catalog=LoginTestDB;Integrated Security=True;Pooling=False" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> 我创建了一个静态类并尝试获取连接字符串。这就是我尝试的方法: static class Helper { public static string ConnectionString { get { string str = System.Configuration.ConfigurationManager.ConnectionStrings["LoginTestDB_cf"].ConnectionString; return str; } } } 然后我尝试像这样访问连接字符串: _myCommand = "my_command_text"; SqlConnection con = new SqlConnection(); con.ConnectionString = Helper.ConnectionString; //getting error _cmd = new SqlCommand(_myCommand, con); con.Open(); 错误:“对象引用未设置到对象的实例。” 我在设置连接字符串时遇到错误。我可以知道这里出了什么问题吗?我确信有一个小错误或无知在扮演肮脏的角色,但无法识别这一点。 在助手类中,我什至尝试过 string str = System.Configuration.ConfigurationManager.AppSettings["LoginTestDB_cf"].ToString(); 但还是没有运气。 谢谢。 好吧,我想出了一个解决方案,并迫切希望有人证明我错了。我将相同的文件(添加现有项目)复制到不同的 Winforms(windowsFormApplication) 解决方案。还有沃拉!!一切都很好。所以现在,我认为连接字符串不能在 UserControl 中使用,尽管我无法证明我所说的合理。但是,是的,我使用了相同的项目文件和相同的 app.config 内容(当然我更改了文件的命名空间名称),一切都很好。如果我的基本知识有误,请告诉我。当然,我会继续在互联网上搜索这个问题。谢谢你。 希望有帮助。 您可以轻松地在新创建的控件中使用连接字符串。 这是我的设置: 用户控制是一个带有您提供的附加代码的按钮。 Helper 类是用户控件的一部分。正如你所看到的,我顺利地通过了它,到达了你遇到问题的开放线路。 (它打开然后关闭连接就很好,我检查过)。 就我而言,我已经解决了!实际上,在用户控件中的事实会稍微改变插入的连接字符串!解决方案只是像在任何其他字符串中一样使用 Replace 方法来恢复这个小更改!要找到差异,只需将连接字符串插入某个面板或文本框中,然后打开该页面的在线版本的 html,将其与正确的连接字符串进行比较。 当然你首先要禁用所有需要连接到在线数据库的东西!

回答 3 投票 0

通过 cli 连接字符串进行数据库更新

对于一个新项目,我正在学习多租户,其中每个租户都有自己的数据库。 这个想法是通过使用 finbuckle nuget 包,它从应用程序设置中获取连接字符串。

回答 1 投票 0

无法通过 .NET 应用程序使用命名管道连接到 SQL Server

首先,我试图完成这项工作,因为我的 Windows 窗体应用程序(从 Windows 10 运行)到我的 Microsoft SQL Server 2012 VM 的“初始连接”花费的时间太长(o...

回答 1 投票 0

从 PowerShell 连接到 SQL Server 数据库

我在网上浏览了一段时间,发现了很多类似的问题,但由于某种原因,我似乎无法正常工作。 我只是想连接到 SQL Server 数据库并输出...

回答 8 投票 0

无法使用 M1 在 MacOS 上通过 Python 连接到 SQL-Server

环境 系统:Darwin内核版本21.6.0 蟒蛇:3.11.1 pyodbc:4.0.35 操作系统:MacOS 蒙特利 (12.6.3) DB:MS SQL Server(在 vscode 上我使用 mssql) 驱动程序:适用于 SQL Server 的 ODBC 驱动程序 18 我是

回答 2 投票 0

如何在没有 odc 文件的情况下从 MS Word 查询数据库?

我想将 SQL Server 数据库中的数据检索到 MS Word 中。我可以通过使用数据库字段代码将以下内容插入按 CTRL 创建的特殊括号中来完成此操作...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.