I am using serenity with postgres and I have generated a new project using visual studio 2019.
I have followed the tutorial of how to make the app connect with Postgresql.
I have created a new database and user in PgAdmin.
I have enabled the app to run migrations when I run my app.
Here is a sample of my connection string.
"Data": {
"Default": {
"ConnectionString": "Server=localhost; Port=5432; User Id=kap_dev; Database=kap_db; Password=kapap_password;",
"ProviderName": "Npgsql"
}
However, I get the error
PostgresException: 3D000: database "kap_dev" does not exist.
The issue is that kap_dev is a user and not a database.
I even posted this error to their git-issues but serenity have not responded with a valid answer.
might be a typo, no space between User and Id
You have to create a database which name is the name of your user "kap_dev".
Related
I'm trying to set up a Debezium SQL Server Connector against a SQL Server instance that is controlled by DBAs at my workplace. I've been able to start up Zookeeper and Kafka Server without issue, and Kafka Connect itself works with sample Connectors, but when attempting to start a Debezium SQL Server Connector instance I've been getting the error "Couldn't obtain database name".
[2022-07-12 16:36:04,269] ERROR Stopping after connector error (org.apache.kafka.connect.cli.ConnectStandalone:117)
java.util.concurrent.ExecutionException: org.apache.kafka.connect.runtime.rest.errors.BadRequestException: Connector configuration is invalid and contains the following 1 error(s):
Unable to connect. Check this and other connection properties. Error: Couldn't obtain database name
Here is my debezium config:
name=Dbz-SqlServer-connector
connector.class=io.debezium.connector.sqlserver.SqlServerConnector
database.hostname=MyDbHost
database.port=1433
database.user=MyUsername
database.password=MyPassword
database.dbname=MyDatabase
database.server.name=MyDbHost
table.include.list=dbo.CdcTest
database.history.kafka.bootstrap.servers=localhost:9092
database.history.kafka.topic=dbhistory.CdcTest
I've tried this in a .properties file passed to a standalone Connect instance, and as a JSON POST to a distributed Connect instance. I have tried all of the same steps on both my local Windows machine as well as on a linux VM, with the same results.
Confluent and Docker are not options for me in this situation.
for SQL Server login credentials, I am using a local account on the SQL Server instance that does have access to the database in question. I found the source code for debezium's connectors on their github and was able to find that specific error message within the code:
private static final String GET_DATABASE_NAME = "SELECT name FROM sys.databases WHERE name = ?";
...
public String retrieveRealDatabaseName(String databaseName) {
try {
return prepareQueryAndMap(GET_DATABASE_NAME,
ps -> ps.setString(1, databaseName),
singleResultMapper(rs -> rs.getString(1), "Could not retrieve exactly one database name"));
}
catch (SQLException e) {
throw new RuntimeException("Couldn't obtain database name", e);
}
}
I'm not completely familiar with Java but it appears that basically something is going wrong when the connector is trying to run "SELECT name FROM sys.databases WHERE name = 'MyDatabase'". When I run this against the database myself, logged in with the same account I'm using, it seems to work just fine, so I'm really not sure where to go from here. It is fair to say that since I'm not in full control of the SQL Server environment that I'm using, there may be some permissions issues that I'm not aware of, but from what I'm able to test it seems like it should be working.
I would greatly appreciate any help at all, whether just suggestions on settings/configs to check or a full-blown solution.
Thank you!
Update: I've built a simple console app to run that sys.databases query against MyDbHost, master database, as the relevant account, and it's working just fine so I feel like that confirms that my connection info is correct and account permissions are also correct. Seems like this is an issue within the Debezium connector.
It turned out that my problem was a mistake in the connector's config setting. I misunderstood which specific pieces of data to put into database.hostname and database.server.name, and one I corrected those fields the connector works.
I have hosting account in plesk panel. I can create and remove a database in hosting panel.
Now I want to create a database from my local computer using add-migration in code first approach. but the following error occurs:
"login failed for the user [myUserId]"
The connection string in appsettings.json is:
"CourseConnection": "Data Source = host-ip,1433; Initial Catalog=mydb;User ID=myuserid;Password=mypassword"
There are two options to create databases on hosting panel:
localhost:3306(default for mysql)
localhost(default for MS sql v13.0...)
I think that provider name is not mentioned in connectionstring but appsettings.json works fine on my local machine without provider name: System.Data.SqlClient.
after hours of try and error , the problem solved as follows:
i created the database in plesk panel and created a new user .
then assign that user to the database . then in package-manager-console applied update-database command to apply migration that was already added.
i used the same connection string in appsettings.json ,it worked successfully.all table created and migration applied .
it may be helpful for someone.
regards
I'm having a problem whenever I try to create a new Cosmos DB database through Azure Portal. I'm using a free subscription so I do not have access to CosmosDB support.
Basically, all values seem to be valid but after creation everything fails. I'm doing the following:
Input a unique ID with no spaces or uppercases or symbols.
Chose "Azure Table" as API type.
Use my "Free Trial" subscription.
Create a new resource group (again with no spaces or uppercases of symbols).
Choose a server in either "South UK" and "North Europe" (tried both on different tries).
Whenever I click finish, after some seconds, I get the following message:
Invalid capability EnableTable. ActivityId: ...
Microsoft.Azure.Documents.Common/1.10.106.1 (Code: BadRequest)
Error Message:
{ "code": "BadRequest", "message": "Invalid capability
EnableTable.\r\nActivityId: 9cb0e2eb-3b62-4bda-a0f9-e3945eb8148b,
Microsoft.Azure.Documents.Common/1.19.106.1" }
I also tried Edge and Chrome and neither work. I find funny that Microsoft says that we can try Azure's CosmosDB for free but in fact we can't because creation fails and they offer no support for free.
You need to use the below url and select the required service to try Cosmos DB free.
I just created one Cosmos SQL DB for free.
https://azure.microsoft.com/en-us/try/cosmosdb/
Problem Solved
Not really sure if this can be considered an answer, but my problem has solved itself somehow. Apparently the solution is to keep trying multiple times till it works.
If it helps the only different thing I did this time was:
Create first an Azure Cosmos MongoDB, including creating a new resource group
Create now the Azure Table DB using the existing resource group used by Mongo DB.
It worked.
Not sure if it was this or and Azure error or subscription issue, since I created my account today, so It could not be properly configured.
I'm facing some troubles with my EF Model.
History: When my app was released in production a few years ago, my EF model was created via the Model First (edmx) technique. I works well on my production server with my SQL SERVER db.
Now I'm doing some improvements on my app, and I decided to leave the Model First technique to go on the Code first technique. It's working great on my localhost, but when I release my new app version on my production server and when my app tries to use the model I got this message:
CREATE DATABASE permission denied in database 'master'.
But I don't get it... My database still exists on my production server (since several years). Why does EF would like to create something? What can be wrong?
Thanks in advance for your answers.
EDIT:
Summary:
For the same database on the same server
For the same connectionstring
For the same EF version (6)
App with Model First works without problem
App with Code First throw exception CREATE DATABASE permission denied in database 'master'.
BUT the database already exists. Why this error? Why does the code first version tries to create a database?
Check this
https://stackoverflow.com/a/19198471/8186328
Be sure that your connection string name is the same that the base constructor of your dbContext
I am trying to deploy a Asp.NET MVC 4 app to a third-party host, and encountered some problems while following this tutorial.
The tutorial created 2 New SQL Server Database, and set the Remote connection string of DefaultConnection to one SQLExpress database and that of SchoolContext to another. However, I want to have only one database, so I only created one New SQL Server Database, and used the same connection string for DefaultConnection AND MyAppContext. Would this cause problem?
Right now my app won't publish with the following error. not sure if it stems from this. MyAppUsr comes from a Grant script, Grant.sql, that I developed from this tutorial.
Error 3 Web deployment task failed. (An error occurred during execution of the database script. The error occurred between the following lines of the script: "8" and "11". The verbose log might have more information about the error. The command started with the following:
"CREATE USER [MyAppUsr] "
The login already has an account under a different user name. http://go.microsoft.com/fwlink/?LinkId=178587 Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SQL_EXECUTION_FAILURE.) 0 0 MvcCP
MyAppContext uses LocalDb instead of SQLExpress. The deployment in the tutorial uses SQLExpress. Can I just create a new SQLExpress database and have MyAppContext (LocalDb) "points to" the SQLExpress database?
You must have run the script at least once prior, correct? Because what it is saying is that the user [MyAppUsr] already exists. You will need to drop the user first, then rerun it. ie:
DROP USER [MyAppUsr]
You can embed that into your script, better yet, put a conditional check if exists...