Grails autoReconnect with SQL Server - sql-server

I'm looking for this information, because everytime SQL Server goes down and ,later, goes up, my Grails 4.0.3 is not able to automatically reconnect with the database.
I don't which configuration to use. In my application.yml I tested autoReconnect=true at the end of the string connection, but it did not work as expected.
url: jdbc:sqlserver://${DATABASE_HOST};databaseName=${CMBARQ_DATABASE_NAME};domain=${DATABASE_INSTANCENAME};autoReconnect=true
Later I saw in the internet this configuration in application.yml, but I think it is exclusive for MySQL, because in all pages I saw it, the database use was MySQL. And I need a configuration like this for SQL Server.
environments:
development:
dataSource:
properties:
dbProperties:
autoReconnect: true
Could anyone help me with this?

Related

Trouble connecting to Microsoft SQL Server with Windows Authentication

I am building a flask project for internal use at my company. I start by using flask and postgre and used sqlalchemy and set up that connection using the model formats like below:
app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)
and that worked well. Now for security reasons we are switching to using Microsoft SQL Server with window authentication on an IIS server but i am having a lot of trouble connecting.
I changed the database URI to
SQLALCHEMY_DATABASE_URI = "mssql+pyodbc://server/database"
I've checked the SQL Sever configuration and I am pretty sure that is correct. However I get the error
psycopg2.OperationalError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
I have researched this issue and have used the pool_pre_ping solution but I get the same error (shown below)
SQLALCHEMY_ENGINE_OPTIONS = {"pool_pre_ping": True}
I have seen a lot of answers around this stuff that use the sqlalchemy.engine stuff but if possible I was hoping to use all of the db.models I have already written out but if that's not possible I can rewrite some stuff. Any help appreciated.
Windows Authentication will become a problem when you deploy to production. I recommend creating a SQL user to connect to your database.
Try this connection string:
mssql+pyodbc://<UID>:<PWD>#<SERVER>/<DATABASE>?driver=ODBC+Driver+17+for+SQL+Server;Trusted_Connection=no
Also make sure you've installed pyodbc msft docs
pip install pyodbc

SqlFileStream error after SQL Server 2016 (SP2-CU3) upgrade (the device is not ready

We've had this .NET component (.exe) running to migrate documents between 2 databases for almost a year. Console app is using the System.Data.SqlTypes.SqlFileStream .NET class to read/write from file system.
After a recent upgrade of SQL Server to SQL Server 2016 (SP2-CU3) (KB4458871) - 13.0.5216.0 (X64) - the console app has stopped working and throws the following error when trying to open specific document for read operation:
System.ComponentModel.Win32Exception (0x80004005): The device is not ready
We double-checked FILESTREAM properties on both databases to make sure they are enabled (just in case they were removed somehow during the upgrade) and we confirmed they are configured as needed.
We are running out of troubleshooting options as we don't know what to check for. All ports seem to be open between the app server where this tool runs and the database servers (same as before).
Let me know if anybody has any idea what could have changed after recent SQL Server upgrade.
just in case someone faces the same issue... we were able to resolve this by actually disabling FILESTREAM, rebooting servers, enabling FILESTREAM back on.
Issue was related to some un-mapped path of physical drives for SQL (sorry i cant provide more details)

DNN - 500 Internal Server error

I recently inhereted a DNN site that has went down as of yesterday (I made no changes to it).
On the front end I see the error
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed."
I looked at the logs in /Portals/_default/Logs and I see
"2018-08-21 05:57:01,024 [WEBA9][Thread:37][ERROR] DotNetNuke.Common.Initialize - The connection to the database has failed, however, the application is already completely installed, a 500 error page will be shown to visitors"
Does anyone know how I could begin to start debugging this? I'm completely new to DNN. Thanks!
You'll want to start by looking at your web.config file in the root of the site.
From there you'll find the connection string. (control-F to search)
Using the Connection information in that connection string, you should try
Try remoting into the database server to see if you can access it via Remote Desktop, can you access it? Does that server need rebooting?
Try connecting to the database using SSMS (SQL Server Management Studio) using the username/pwd in the connection string.
I imagine that the SQL server is for some reason offline, and you'll need to get it back up and running.
It can happen after a reboot of the server. When IIS with the DNN site comes online earlier than the SQL server is done loading.
Stopping and starting the AppPool of the DNN installation might help.

Cannot execute EF Core migration on remote Azure SQL Server database - No such host is known

I try to execute migration on remote, Azure SQL Server database.
Command:
dotnet ef --startup-project ./../Teamdare.Bot database update -e Production
Connection string in appsettings.Production.json:
"ConnectionString": "Server=tcp:project.database.windows.net,1433;Database=project;Persist Security Info=False;User ID=login#project;Password=projectPassword;"
The migrations work for local database and database credentials are correct as well - they work with previous app and by db GUI client.
The error:
One or more errors occurred. (No such host is known)
I tried some variations of connection string, this one seem to be most similar to one provided here: https://www.connectionstrings.com/sql-azure/
The thing was I was using wrong handler - I stayed with the one used for PostgreSQL database, which we use for local developement.

Anylogic 7.2 database object conectivity to SQL Server

I have a problem with the Anylogic 7.2 database object connecting to SQL Server. I am new to Anylogic, but as far as I can tell I have set it up correctly. To set up connectivity to SQL Server, I downloaded sqljdbc4-3.0.jar and set it as a model dependency in the top level model. In the 'imports' section of 'main', I call import com.microsoft.sqlserver.jdbc.SQLServerDriver;
The user login has the relevant privileges to the database in question, and the username/password combination work. The user can connect through SQL Server Management Studio.
In the Anylogic database connection wizard I have set host to (local), ., local, localhost, (localhost) - none appear to work. When I try to connect to return the list of tables, the result returned is null.
I am not knowledgeable of SQL Server, but I think it is set up properly. I am all out ideas and not sure how to resolve this one. If anybody has a clue I would be very grateful to hear.
Thanks.
Thanks for your help Rachel. Eventually I got to the bottom of this one. After going through log files from Anylogic and SQL Server it became clear that Anylogic was failing to reach SQL Server, i.e. there was no attempt to login. So, I turned off my firewall and all worked as intended. It seemed that the firewall was blocking communication on port 1433. I set up explicit firewall rules to allow communication over ports 1433 and 1434 and now the issue appears to be resolved.

Resources