Error Database connection with user and password info - mysql

I have a connection to a data base and every time there is a problem connecting I get this error.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on '205.178.146.104' (4)' in /data/18/2/77/115/2566441/user/2813515/htdocs/ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace:
#0 .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:dbname=si...', 'xxx', 'xxx', Array)
#1 .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#2 .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Abstract.php(459): Zend_Db_Adapter_Pdo_Mysql->_connect()
#3 .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `user`', Array)
#4 .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Mysq in .../ZendFramework-1.11.5/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144
The thing is that the database user and password are visible on the page in the error message. Is there a way that I can prevent PHP from showing that info? Or is this happening because I am set up a a developing instead of production?

It is a combination of both. In development, your showing your errors. Which is the primary reason your seeing that.
However, you can catch the exception by testing the connection before the query. Allowing you to handle your own connection failures.
try {
Zend_Db_Table::getDefaultAdapter()->getConnection();
} catch (Zend_Exception $e) {
throw new Zend_Exception("A different error");
}

It is because you are on "developing" (exceptions are shown in browser)
Solution 1: Use Production Environment ;)
Solution 2: Change settings in application.ini
Solution 3: Use an try/catch block for database connect

Related

Perch CMS isn't connecting to my XAMPP database

I'm just trying to install Perch CMS into my site locally. At setup, I put in my XAMPP database server host name, username and I leave the password blank because that is how it is meant to be. But it shows me this error code when I try to move forward:
Fatal error: Uncaught Error: Undefined constant "PERCH_DB_PASSWORD" in C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php:46 Stack trace: #0 C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php(46): constant('PERCH_DB_PASSWO...') #1 C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php(75): PerchDB_MySQL->config('PERCH_DB_PASSWO...') #2 C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php(117): PerchDB_MySQL->open_link() #3 C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php(460): PerchDB_MySQL->get_link() #4 C:\xampp\htdocs\dschc\cms\setup\PerchSetup_Installation.class.php(13): PerchDB_MySQL->test_connection() #5 C:\xampp\htdocs\dschc\cms\setup\database\index.php(50): PerchSetup_Installation->test_db(Array) #6 {main} thrown in C:\xampp\htdocs\dschc\cms\core\lib\PerchDB_MySQL.class.php on line 46
P.S I have never changed my database connection credentials since I installed XAMPP

Calling createEntityManager in CORBA program causes exception: org.omg.CORBA.OBJECT_NOT_EXIST

I have a CORBA client-server program that is working perfectly. The client can get a servant and call methods remotely.
I would now like to make the server interact with a database using JPA. However everything goes wrong when I add this one line to the server code:
emf.createEntityManager();
The server builds, and it registers to the orbd without error. However when I run the client which tries to connect with the server I get the following exception:
Exception: org.omg.CORBA.OBJECT_NOT_EXIST:
Full exception and stack trace are:
Exception: org.omg.CORBA.OBJECT_NOT_EXIST: ----------BEGIN server-side stack trace----------
org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: SUN minor code: 401 completed: No
at com.sun.corba.se.impl.logging.ActivationSystemException.errorInBadServerIdHandler(ActivationSystemException.java:239)
at com.sun.corba.se.impl.logging.ActivationSystemException.errorInBadServerIdHandler(ActivationSystemException.java:257)
at com.sun.corba.se.impl.activation.ServerManagerImpl.handle(ServerManagerImpl.java:604)
at com.sun.corba.se.impl.orb.ORBImpl.handleBadServerId(ORBImpl.java:1602)
at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.checkServerId(CorbaServerRequestDispatcherImpl.java:407)
at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:182)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1700)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1558)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:940)
at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:198)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:712)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:471)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1230)
at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:490)
at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:519)
Caused by: com.sun.corba.se.spi.activation.ServerNotRegistered: IDL:activation/ServerNotRegistered:1.0
at com.sun.corba.se.impl.activation.RepositoryImpl.getDBServerDef(RepositoryImpl.java:221)
at com.sun.corba.se.impl.activation.RepositoryImpl.getServer(RepositoryImpl.java:228)
at com.sun.corba.se.impl.activation.ServerManagerImpl.getEntry(ServerManagerImpl.java:350)
at com.sun.corba.se.impl.activation.ServerManagerImpl.handle(ServerManagerImpl.java:566)
... 12 more
To my mind, a call to createEntityManager is logically completely separate from the CORBA networking functionality, so I can't see how this could possible have an impact on the client connecting to the server.
The exception was coming from my EntityManagerFactory. It had nothing to do with the networking, but because I never ran the server until a client connected, no exception occurred until that point.
The exception output was not particularly useful. I found it helpful to comment out all the networking code and just run the server as a stand-alone program from development (much more useful error messages when something goes wrong).

MySQL fatal error during information_schema query (software caused connection abort)

I'm using MySQL server (5.6) database extensively through its .NET connector (6.8.3). All tables are created with MyISAM engine for performance reasons. I have only one process with one thread accessing the DB sequentially, so there is no need for transactions and concurrency.
Please note: this is unlikely to be a timeout configuration issue, because my query is trivial. I did read all timeout related questions (links below). Of course, I may be wrong, but saying just "increase the net_write_timeout parameter" without explaining why exactly it can be relevant here is not an answer.
Some of my tables are created dynamically during program execution so I'm using create on first use idiom, with the following method to check whether the table exists:
private bool TableExists(Space baseSpace, Space extendedSpace)
{
var tableName = GenerateTableName(baseSpace, extendedSpace);
var sqlConnection = this.connectionPool.Take();
this.existsCommand.Connection = sqlConnection;
this.existsCommand.Parameters["#tableName"].Value = tableName.Trim('`');
var result = existsCommand.ExecuteScalar() as long?;
this.connectionPool.Putback(sqlConnection);
return result == 1;
}
The query inside the existsCommand is as follows (broken into two lines here for readability):
SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema = 'my_schema' AND table_name = #tableName
The value of this.existsCommand.Parameters["#tableName"].Value variable contains the correct name of the table, that already exists in this case ("sample_matches_A_to_A_x").
The this.connectionPool.Take() method returns the first MySqlConnection object from my collection of available connections that meets the following predicate:
private bool IsAvailable(MySqlConnection connection)
{
return connection != null
&& connection.State == System.Data.ConnectionState.Open;
}
Usually this works correctly, for a number of hours and then suddenly an exception occurs on this line:
var result = existsCommand.ExecuteScalar() as long?;
With the following contents:
Fatal error encountered during command execution
Stack trace:
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteScalar()
at implementation.SampleMatchesMySqlTable.TableExists(Space baseSpace, Space extendedSpace) in C:...\SampleMatchesMySqlTable.cs:line 168
Inner exception:
Unable to write data to the transport connection: Software caused connection abort.
Inner exception:
Software caused connection abort.
with ErrorCode equal to 10053 and SocketErrorCode being System.Net.Sockets.SocketError.ConnectionAborted
Stack trace of the innermost exception:
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
I've reviewed the following possible duplicates and unfortunately they don't seem relevant here, except one:
SHOW TABLES encountered Fatal error encountered during command execution
Unfortunately, it doesn't provide enough information to decide whether it is an exact duplicate nor it's answered.
There relate to timeout problems. My query is small, returns only one integer, and searches for a table in a meta-table containing something like 20 other tables.
Fatal error encountered during command execution. in C# when i use Insert Into
https://stackoverflow.com/questions/7895178/fatal-error-in-mysql
MySQL Exception - Fatal Error Encountered During Data Read
Fatal error encountered during data read
Fatal error causing timeout -mysql
ADO.Net Entity framework, Fatal error encountered during data read
Different error regarding reading the resultset:
Fatal error encountered during command execution
Syntax errors and connection string issues:
Mysql Fatal error encountered during command execution
fatal error encountered during execution... during update
Fatal error encountered during command execution
fatal error encountered during command execution during update
fatal error encountered during command execution c# mysql
Fatal error encountered during command execution with a mySQL INSERT
I have Fatal error encountered during command execution
MySql exception was unhandled - Fatal error encountered during command execution
https://stackoverflow.com/questions/24098561/mysql-fatal-error-encountered-during-command-execution-in-c-sharp
Fatal Error Encounter During Command Execution MySQL VB
"Fatal error encountered during command execution." mysql-connector .net
"Fatal error encountered during command execution."
C#, MySQL - fatal error encountered during command execution- Checked other solutions, something I am Missing
Creating a view:
"fatal error encountered during command execution" when trying to add a view from MySQL DB
Reading CSV files:
Fatal error encountered during command execution while importing from csv to mysql
MySQL fatal error encountered during command execution - looping through all csv files in folder for load data local infile
I ended up modifying the IsAvailable method as follows:
private bool IsAvailable(MySqlConnection connection)
{
var result = false;
try
{
if (connection != null)
{
result = connection.Ping();
}
}
catch (Exception e)
{
Console.WriteLine("Ping exception: " + e.Message);
}
return result && connection.State == System.Data.ConnectionState.Open;
}
The .Ping call seems to be better in verifying connection's state then its properties, although it's very poorly documented. From some other sources I've read in the meantime:
an alternative is to run a simple query like SELECT 1 FROM DUAL instead of calling Ping.
Also, there seems that sometimes a DataReader, even though it was disposed (everything is implemented with the using statement), is still attached to the connection for some brief period of time. Because of this I've modified the condition to this:
if (connection != null && connection.State == ConnectionState.Open)
The State property has the Executing value as long as a DataReader is attached to it, so additionally verifying if it's Open at the beginning works fine here.

Reindexing error in 1.6 (PHP exception in indexer.php)

Recently I upgraded from 1.4.2 to 1.6.2. Things actually went fairly smoothly, which was relatively surprising. Until I tried to reindex my store. Using the GUI backend gives me the typical no help "Cannot Initialize the indexer process" message. So I tried running indexer.php from the command line (php shell/indexer.php reindexall) which gives me this error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' in /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace:
0 /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:model=mys...', 'shopchau_stage', 'gr8target', Array)
1 /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
2 /home/shopchau/public_html/stage/lib/Varien/Db/Adapter/Pdo/Mysql.php(300): Zend_Db_Adapter_Pdo_Mysql->_connect()
3 /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Abstract.php(459): Varien_Db_Adapter_Pdo_Mysql->_connect()
4 /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SET NAMES utf8', Array)
5 /home/shopchau/public_html/stage/lib/Varien/Db/Adapter/Pdo/Mysql.php(389): Zend_Db_Adapter_Pdo_Abstract->query('SET NAMES utf8', Array)
in /home/shopchau/public_html/stage/lib/Zend/Db/Adapter/Pdo/Abstract.php on line 144
Now I've tried the various fixes here: delete the locks, delete cache, fixing file permissions, and running checks to see if my DB is corrupt. Far as I can tell, everything else is working. Nothing so far, has helped this issue.
Anyone have any ideas/fixes?
That exception tells about connection problem. Are you sure MySQL uses /var/lib/mysql/mysql.sock socket? Try changing it to /tmp/mysql.sock. You can adjust this in your local.xml

Unable to rescue from "Lost connection to MySQL server" error

I have a block like so:
begin
# some SQL request
rescue Mysql::Error => e
logputs "Mysql::Error occurred, retrying in 10s: #{e.message}"
sleep 10
retry
end
But when a "Lost connection to MySQL server" error occurred, this block was not able to catch it and retry (the MySQL server was restarted). Any idea how I can properly catch this exception?
Thanks!
From your comment it looks like what's happening is that a Mysql::Error exception is being thrown, but then caught by ActiveRecord which then throws an ActiveRecord::StatementInvalid exception (which isn't very helpful behaviour in this case!).
I'd say change your rescue to catch the AR::StatementInvalid exception and see what that does for you.
Are you sure you are rescuing the correct type of exception?
Try using the following code:
rescue StandardError => e
puts e
That should output any exception that is raised and more importantly you will be able to see the specific type. Then you can adjust your rescue statement to be more specific.