I'm using Laravel-7 and MySQL SERVER for my project. How can I get the status of DB connection?
I have already tried few methods, but it did not work. I want to get the status and display the custom success or error status.
My code is below:
try{
DB::connection()->getDatabaseName();
return redirect('/registration')->with('db_con_status','Database connected!');
}catch(Illuminate\Database\QueryException $dbexp){
return redirect('/registration')->with('db_con_error',$dbexp->getMessage());
}
but it still shown Laravel in-built ignition error like...
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. (SQL: select count(*) as aggregate from users where email = abc#xyz.com)
How to catch that exception and handle it?
I think your xamp is running in background. Open task manager and stop it from there (if you use windows).
Related
In my node.js app I use the knex to connect to to mysql db
now I got many of warning messages:
Error: Connection lost: The server closed the connection. Ignoring invalid configuration option passed to Connection: reconnect. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
I want to know what can I do to fix it and remove this message
While looking for result there is a link to the problem here
https://github.com/sidorares/node-mysql2/blob/master/lib/connection_config.js#L64-L74
Then I found the problem
In heroku the api add "?reconnect=true" to the connection
https://devcenter.heroku.com/articles/cleardb#provisioning-the-shared-mysql-add-on
this query string create the error.
So now I don't know what needed to be done.
Add the ?"reconnect=true" to the connection like heroku recommend
Or remove this parameter like the warning
I want to connect to MySQL database using HTTP Tunnel (because port for remoting database is closed). I used mysqlDAC vcl for Delphi, when I was in design mode, i used GridView to display its data successfully.
But the problem when i compile the project, I always get this error :
Project WP.exe raised exception class HttpException with message 'Error on data reading from the connection:
A blocking operation was interrupted by a call to WSACancelBlockingCall.
Socket Error Code: 10004($2714)'. Process stopped. Use Step or Run to continue.
Can somebody help me to solve this problem? I think my connection setup is correct, because I can display the data on DBGrid when I set connection is true.
I have Mysql DB connected to .NET MVC. When i connect remote it some times works fine and some times i have this error msg:
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to
host 'ServerName' for user 'UserName' using method
'mysql_native_password' failed with message: Reading from the stream
has failed. ---> MySql.Data.MySqlClient.MySqlException (0x80004005):
Reading from the stream has failed. ---> System.IO.IOException: Unable
to read data from the transport connection: An established connection
was aborted by the software in your host machine. --->
System.Net.Sockets.SocketException: An established connection was
aborted by the
Please how can i make Authentication ? Any ideas to solve it?
This is a common error when some kind of deadlock occurs on the database more commonly a connection has been open a long time and gets shut down at the database end even though it is still in-use in your web application.
In my code, I used a suggestion from Microsoft, that retries the database command if it fails. The link is here: http://social.technet.microsoft.com/wiki/contents/articles/4235.retry-logic-for-transient-failures-in-windows-azure-sql-database.aspx Similar things exist for other non-Azure problems that use RetryPolicy.
What this means in a simple (Azure in my case) example is:
private static RetryPolicy<SqlAzureTransientErrorDetectionStrategy> retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(new Incremental(3, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1)));
// Inside your database function
retryPolicy.ExecuteAction(() =>
{
db.ExecuteStoredProc("procRecordMetric", cmd);
});
In my case, this was caused by ssl being enabled on the mysql server.
Here is a snippet from my.cnf
#ssl-ca = /etc/ssl/mysql/ca-cert.pem
#ssl-cert = /etc/ssl/mysql/server-cert.pem
#ssl-key = /etc/ssl/mysql/server-key.pem
Commenting these 3 lines fixed the issue for me.
I installed MySQL server and I also test this server by creating user data base userlist table and also check that it is working fine on command line as I previously done. But This time getting error when try to create a user.
I already used this but actauly I format my system and creating connection again. But this time getting error.
I have prepared a program with Visual Studio 2010 and I'm working with SQL Server 2008. Before 2 weeks ago, this connection was working properly. Now, I'm trying to use it again. When I'm clicking on the Connect button, it waits, and then gives this error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
is not accessible. Verify that the instance name is correct and that
SQL Server name is configured to allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified.)
I googled this issue, but nothing helps.
I will be grateful to help me with this issue.
Do ensure that service is running. You can check this by writing this query on the query analyser as:-
IF EXISTS (SELECT 1 FROM sysprocesses WHERE LEFT(program_name, 8) = 'SQLAgent')
PRINT 'Running!'
ELSE
PRINT 'Not running';
From here:-
Make sure your server name is correct, e.g., no typo on the name.
Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application
converts \ to . If you are not sure about your application, please
try both Server\Instance and Server\Instance in your connection
string]
Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).
Make sure SQL Browser service is running on the server. If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.
Open command prompt and execute this code:
For default instance : NET START MSSQLSERVER
For named instance : NET START MSSQL$