phaneendra

This user hasn't shared any biographical information

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)


Problem: While connecting to MySQL from command line on MySQL 5.7, receiving the below error

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)

Solution: To solve this problem, download an older version from the archives, say 5.6.28 and copy the “data” folder under mysql-5.6.28-winx64 to mysql-5.7.11-winx64

http://downloads.mysql.com/archives/community/

Once data folder is copied, open a command prompt in admin mode and navigate to bin directory and uninstall existing MSQL service

C:\mysql-5.7.11-winx64\bin>sc delete MySQL

After existing MySQL service is uninstalled, install MySQL service again

C:\mysql-5.7.11-winx64\bin>mysqld –install
Service successfully installed.

C:\mysql-5.7.11-winx64\bin>mysqld start

now open a commnad prompt and type services.msc, if MSQL service is not running, open the service and start.

Once the sercice is running, test the connection using MySQL Workbench. When trying to connect using workbench, you will receive the below error

Table ‘performance_schema.session_variables’ doesn’t exist

This is because we copied data folder from an older version of mysql to a new version. If you do not copy, mysql wont even start in the first place. To resolve performance_schema table issue, lets upgrade the mysql as shown below.

C:\mysql-5.7.11-winx64\bin>mysql_upgrade -u root -p –force
Enter password:
Checking server version.
Running queries to upgrade MySQL server.
Checking system database.
mysql.columns_priv OK
mysql.db OK
mysql.engine_cost OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.gtid_executed OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK

Leave a comment

Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to detect defaults for context configuration


Problem: Running JUnit 4 with Spring 3 and getting below exception

 

Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to detect defaults for context configuration

 

Solution: Add locations attribute to the contextConfiguration.

@ContextConfiguration(locations = {“classpath:applicationContext.xml”}) for the JUnit to refer to the beans Definition.

 

 

Leave a comment

Cannot execute mojo: resources. It requires a project with an existing po m.xml, but the build is not using one.


Problem: Cannot execute mojo: resources. It requires a project with an existing po
m.xml, but the build is not using one.

This error simply means there is not pom.xml in the working directory. From the path,where the mvn jetty:run is being run, pom.xml does not exist.

Navigate to the right directory and run the command being tried again should resolve the issue.

Leave a comment

The plugin ‘org.apache.maven.plugins:maven-jetty-plugin’ does not exist o r no valid version could be found


Problem: The plugin ‘org.apache.maven.plugins:maven-jetty-plugin’ does not exist o
r no valid version could be found

 

Performing mvn jetty:run is throwing this error and infact maven-jetty-plugin does not exist in pom.xml. Instead of adding it every pom.xml that tries to use jetty, instead plug-in is added to settings.xml as below

 

<pluginGroups>
<!– pluginGroup
| Specifies a further group identifier to use for plugin lookup.
<pluginGroup>com.your.plugins</pluginGroup>
–>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>

Leave a comment

How to search a string in clob column in oracle


Problem: How to search for a string in a CLOB Column

Solution: Suppose you have a table with a CLOB column and you want to search for an occurence of the string in the clob column, you can do like

SELECT *FROM TABLE_NAME WHERE DBMS_LOB.INSTR(CLOB_COLUMN_NAME, ‘SEARCHSTRING’,1,1)>0

Replace with your table name, CLOB Column name in the table and with the actual search string.

Leave a comment

ORA-04091:table is mutating, trigger/function may not see it


Problem: ORA-04091:table is mutating, trigger/function may not see it

Solution: There are various solutions to solve this, however it requires deeper understanding on what mutating error is and how to resolve this. You will encounter this when working on a trigger for a particular table and the trigger code is accessing the same table on which the trigger is operating on.

Simple solution is to remove references to any usage of the table on which trigger is operating on, if at all possible. How ? Go on…

If you have a ORDER table that has ORDER_ID AND CUSTOMER_ID AND LAST_UPDATED

An ORDER_DETAILS table with ORDER_ID,ORDER_DETAILS.

Suppose the trigger is on the ORDERS table FOR EACH ROW and BEFORE  UPDATE. Trigger is to update  the ORDER_DETAILS table for a particular existing order along with updating the timestamp in ORDERS table. To do so, if you try to access the ORDER_DETAILS as below, you will end up with mutating error, as in

SELECT ORDER_DETAILS INTO DETAILS

FROM ORDERS O, ORDER_DETAILS OD

WHERE O.ID = OD.ID AND O.ID = :OLD.ID

I have added some reference down below to understand :NEW and :OLD for those who want to understand how to use them in triggers. In the above query, problem is trigger is on ORDERS table and trigger is also trying to access the ORDERS table. Here there is no need to access ID from ORDERS table to join with ORDER_DETAILS Details.   

Instead, simplify the query by removing the references to ORDERS table to avoid mutating error

SELECT ORDER_DETAILS INTO DETAILS

FROM  ORDER_DETAILS OD

WHERE OD.ID  = :OLD.ID

Identifying scenarios like this before dwelling into complex solutions will save time 🙂

Accessing Column Values in Row Triggers

Within a trigger body of a row trigger, the PL/SQL code and SQL statements have access to the old and new column values of the current row affected by the triggering statement. Two correlation names exist for every column of the table being modified: one for the old column value, and one for the new column value. Depending on the type of triggering statement, certain correlation names might not have any meaning.

  • A trigger fired by an INSERT statement has meaningful access to new column values only. Because the row is being created by the INSERT, the old values are null.
  • A trigger fired by an UPDATE statement has access to both old and new column values for both BEFORE and AFTER row triggers.
  • A trigger fired by a DELETE statement has meaningful access to :old column values only. Because the row no longer exists after the row is deleted, the :new values are NULL. However, you cannot modify :new values:ORA4084 is raised if you try to modify :new values.

The new column values are referenced using the new qualifier before the column name, while the old column values are referenced using the old qualifier before the column name. For example, if the triggering statement is associated with the Emp_tab table (with the columns SALCOMM, and so on), then you can include statements in the trigger body. For example:

IF :new.Sal > 10000 ...
IF :new.Sal < :old.Sal ...

1 Comment

java.sql.SQLException: Protocol violation


Problem: Getting SQL Exception java.sql.SQLException: Protocol violation

Solution: I had researched various available solutions for this issue, however none of them solved my issue. I will first summarize some available solutions before presenting what solved the problem in a different way

 

Solution 1:   DB  password was showing an error ORA-28002: the password will expire within XX day. Reseting the password resolves the issue

Solution 2: use 64 bit VM. To use 64 bit VM pass argument -d64 as command line parameter to Java.

Solution 3: In My case, its the JVM Settings. Increasing the -Xmx<size> set maximum Java heap size

Increasing from -Xmx512M to -Xmx1024M resolved the issue as well

Leave a comment