Saturday, 14 April 2018

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

I just downloaded the mysql and tried to run the command ‘mysql -h localhost -u root -p’.

Unfortunately, I end up in below error.

C:\>mysql -h localhost -u root -p
Enter password: ****
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

After some analysis, I realized that the MySQL server is not running. You need to start the mysql server to resolve this issue.

Open Windows prompt, and search for services.



You can able to see ‘Services’ gear icon. Click on that.


Check for MySQL and start the service.



Previous                                                 Next                                                 Home

ASN.1: REAL: Working with decimal numbers

Type: REAL        

Description: Represent decimal point numbers.

You can represent real numbers in 2 ways.
         Decimal format like 546789.239
         Sequence format like {mantissa 546789239, base 10, exponent -3}.

Example
salary REAL

Example Schema
Employee ::= SEQUENCE {
    name VisibleString,
    id VisibleString,
    salary REAL
}

Sample data for above schema
emp Employee ::= {
 name "Rama Krishna",
 id "I123456",
 salary 546789.239
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <id>I123456</id>
  <salary>546789.239</salary>
</Employee>


Sample data for above schema using mantissa notation
emp Employee ::= {
 name "Rama Krishna",
 id "I123456",
 salary {mantissa 546789239, base 10, exponent -3}
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <id>I123456</id>
  <salary>5.46789239E5</salary>
</Employee>








Previous                                                 Next                                                 Home

Friday, 13 April 2018

jsizer: Visualize the complexity of java project


jsizer is a small swing based application, that reads the jar file and shows the complexity of the jar file in a graph.

The graph has nodes in it and the nodes get their color, size depends on few things.
a.   Green nodes are packages
b.   Grey nodes are classes

The class nodes get their size and color from some metrics.
The default metrics are:
a.   Width represents the number of fields in the class
b.   Height represents the number of methods in the class
c.   Color represents the number of lines of code in the class, a dark node has more lines of code than a light node.

You can find the big dark boxes and possibly refactor them.

You can download the jsizer from below url.

Extract the binary zip file that you downloaded. You can able to see ‘jsizer.jar’.

Open command prompt (or) terminal and run ‘java -jar jsizer.jar’.


File -> Add Jar

After adding the jar, you can able to see below kind of user interface.


You may like

ASN.1: DATE-TIME: Represent date and time together

Type: DATE-TIME

Description: It is used to represent date and time together. "YYYY-MM-DDTHH:MM:SS"      

Example
startTime "2018-02-06T06:30:23"

Example Schema
Event ::= SEQUENCE {
    eventName VisibleString,
    startTime DATE-TIME,
    endTime DATE-TIME
}

Sample data for above schema
eventOne Event ::= {
 eventName "Under 19 Tennis",
 startTime "2018-02-06T06:30:23",
 endTime "2018-02-23T18:30:23"
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Event>
  <eventName>Under 19 Tennis</eventName>
  <startTime>2018-02-06T06:30:23</startTime>
  <endTime>2018-02-23T18:30:23</endTime>
</Event>



Previous                                                 Next                                                 Home

Java: Get country and the currency of the country

package com.sample.test;

import java.util.Currency;
import java.util.Locale;

public class Test {

 public static void main(String args[]) throws Exception {
  System.out.println("Country : Currency Code : Display Name");
  for (Locale locale : Locale.getAvailableLocales()) {
   String country = locale.getDisplayCountry();

   Currency currency = null;
   try {
    currency = Currency.getInstance(locale);
   } catch (IllegalArgumentException e) {
    continue;
   }

   String currencyCode = currency.getCurrencyCode();
   String displayName = currency.getDisplayName();

   System.out.println(country + " : " + currencyCode + " : " + displayName);
  }
 }
}

Output

Country : Currency Code : Display Name
United Arab Emirates : AED : United Arab Emirates Dirham
Jordan : JOD : Jordanian Dinar
Syria : SYP : Syrian Pound
Croatia : HRK : Kuna
Belgium : EUR : Euro
Panama : PAB : Panamanian Balboa
Malta : EUR : Euro
Venezuela : VEF : Venezuelan Bolívar
Taiwan : TWD : New Taiwan Dollar
Denmark : DKK : Danish Krone
Puerto Rico : USD : US Dollar
Vietnam : VND : Vietnamese Dong
United States : USD : US Dollar
Montenegro : EUR : Euro
Sweden : SEK : Swedish Krona
Bolivia : BOB : Bolivian Boliviano
Singapore : SGD : Singapore Dollar
Bahrain : BHD : Bahraini Dinar
Saudi Arabia : SAR : Saudi Riyal
Yemen : YER : Yemeni Rial
India : INR : Indian Rupee
Malta : EUR : Euro
Finland : EUR : Euro
Bosnia and Herzegovina : BAM : Bosnia-Herzegovina Convertible Mark
Ukraine : UAH : Ukrainian Hryvnia
Switzerland : CHF : Swiss Franc
Argentina : ARS : Argentine Peso
Egypt : EGP : Egyptian Pound
Japan : JPY : Japanese Yen
El Salvador : SVC : Salvadoran Colón
Brazil : BRL : Brazilian Real
Iceland : ISK : Icelandic Króna
Czech Republic : CZK : Czech Republic Koruna
Poland : PLN : Polish Zloty
Spain : EUR : Euro
Serbia and Montenegro : CSD : Serbian Dinar (2002-2006)
Malaysia : MYR : Malaysian Ringgit
Spain : EUR : Euro
Colombia : COP : Colombian Peso
Bulgaria : BGN : Bulgarian Lev
Bosnia and Herzegovina : BAM : Bosnia-Herzegovina Convertible Mark
Paraguay : PYG : Paraguayan Guarani
Ecuador : USD : US Dollar
United States : USD : US Dollar
Sudan : SDG : Sudanese Pound
Romania : RON : Romanian Leu
Philippines : PHP : Philippine Peso
Tunisia : TND : Tunisian Dinar
Montenegro : EUR : Euro
Guatemala : GTQ : Guatemalan Quetzal
South Korea : KRW : South Korean Won
Cyprus : EUR : Euro
Mexico : MXN : Mexican Peso
Russia : RUB : Russian Ruble
Honduras : HNL : Honduran Lempira
Hong Kong : HKD : Hong Kong Dollar
Norway : NOK : Norwegian Krone
Hungary : HUF : Hungarian Forint
Thailand : THB : Thai Baht
Iraq : IQD : Iraqi Dinar
Chile : CLP : Chilean Peso
Morocco : MAD : Moroccan Dirham
Ireland : EUR : Euro
Turkey : TRY : Turkish Lira
Estonia : EUR : Euro
Qatar : QAR : Qatari Rial
Portugal : EUR : Euro
Luxembourg : EUR : Euro
Oman : OMR : Omani Rial
Albania : ALL : Albanian Lek
Dominican Republic : DOP : Dominican Peso
Cuba : CUP : Cuban Peso
New Zealand : NZD : New Zealand Dollar
Serbia : RSD : Serbian Dinar
Switzerland : CHF : Swiss Franc
Uruguay : UYU : Uruguayan Peso
Greece : EUR : Euro
Israel : ILS : Israeli New Sheqel
South Africa : ZAR : South African Rand
Thailand : THB : Thai Baht
France : EUR : Euro
Austria : EUR : Euro
Norway : NOK : Norwegian Krone
Australia : AUD : Australian Dollar
Netherlands : EUR : Euro
Canada : CAD : Canadian Dollar
Latvia : EUR : Euro
Luxembourg : EUR : Euro
Costa Rica : CRC : Costa Rican Colón
Kuwait : KWD : Kuwaiti Dinar
Libya : LYD : Libyan Dinar
Switzerland : CHF : Swiss Franc
Germany : EUR : Euro
Algeria : DZD : Algerian Dinar
Slovakia : EUR : Euro
Lithuania : EUR : Euro
Italy : EUR : Euro
Ireland : EUR : Euro
Singapore : SGD : Singapore Dollar
Canada : CAD : Canadian Dollar
Belgium : EUR : Euro
China : CNY : Chinese Yuan
Japan : JPY : Japanese Yen
Greece : EUR : Euro
Serbia : RSD : Serbian Dinar
India : INR : Indian Rupee
Lebanon : LBP : Lebanese Pound
Nicaragua : NIO : Nicaraguan Córdoba
Macedonia : MKD : Macedonian Denar
Belarus : BYN : Belarusian Ruble
Slovenia : EUR : Euro
Peru : PEN : Peruvian Sol
Indonesia : IDR : Indonesian Rupiah
United Kingdom : GBP : British Pound Sterling



ASN.1: TIME-OF-DAY: Represent time of the day

Type: TIME-OF-DAY

Description: Used to represent time of the day. It is of the form "HH:MM:SS".

Example
startTime TIME-OF-DAY,
endTime TIME-OF-DAY

Example Schema
Event ::= SEQUENCE {
    eventName VisibleString,
    startTime TIME-OF-DAY,
    endTime TIME-OF-DAY
}

Sample data for above schema
eventOne Event ::= {
 eventName "Under 19 Tennis",
 startTime "18:30:23",
 endTime "18:30:23"
}

XML encoding of above data
<?xml version="1.0" encoding="UTF-8"?>
<Event>
  <eventName>Under 19 Tennis</eventName>
  <startTime>18:30:23</startTime>
  <endTime>18:30:23</endTime>
</Event>


Previous                                                 Next                                                 Home

Thursday, 12 April 2018

ASN.1: DATE: Working with dates

Type: DATE

Description: Used to represent date. It should be of the form "YYYY-MM-DD".   

Example
dateOfBirth DATE

Example Schema
Occupation ::=  BIT STRING {
    clerk        (0),
    watchman     (1),
    engineer     (2),
    manager      (3)
}
    
Hobbies ::= BIT STRING {
    chess     (0),
    cricket   (1),
    hockey    (2),
    football  (3),
    others    (4)
}
    
Employee ::= SEQUENCE {
 name VisibleString,
 isPermanentEmployee BOOLEAN,
 id VisibleString,
 age INTEGER (15..60),
 occupation Occupation,
 hobbies Hobbies,
 dateOfBirth DATE
}

Sample data for above schema
employee1 Employee ::= {
 name "Rama Krishna",
 isPermanentEmployee FALSE,
 id "123456",
 age 30,
 occupation '010'B,
 hobbies {chess, football},
 dateOfBirth "1988-05-05"
}

XML encoding of above data

<?xml version="1.0" encoding="UTF-8"?>
<Employee>
  <name>Rama Krishna</name>
  <isPermanentEmployee><false/></isPermanentEmployee>
  <id>123456</id>
  <age>30</age>
  <occupation>01</occupation>
  <hobbies>1001</hobbies>
  <dateOfBirth>1988-05-05</dateOfBirth>
</Employee>



Previous                                                 Next                                                 Home