Tuesday, 16 August 2016

[RCP] How to remove unnecessary unnecessarypreference pages (불필요 Preference Page 제거)



If you want to remove unnecessary preference pages(Maven and Mylyn),

add commands in postWindowOpen() method which is in ApplicationWorkbenchWindowAdvisor class.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    @Override
    public void postWindowOpen() {
     ...
     
     PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager();
     // For checking preference nodes id
//     org.eclipse.jface.preference.IPreferenceNode[] nodes = pm.getRootSubNodes();
//     for ( int ll = 0; ll < nodes.length; ll++) {
//      System.out.println( nodes[ ll].getId());
//     }
     pm.remove( "org.eclipse.m2e.core.preferences.Maven2PreferencePage");
     pm.remove( "org.eclipse.mylyn.preferencePages.Mylyn");
     
     
 }

Friday, 12 August 2016

[Oracle] ORA-28001: the password has expired (Unlock user has expired password)



If you try to log in invalid password  continuously, the user is locked. This is a solution that unlock user.


$> sqlplus / as sysdba

ALTER USER [USER_NAME] ACCOUNT UNLOCK;


[Oracle] ORA-00845 : MEMORY TARGET not supported on this system2

I used Oracle 11g in CentOS VM image. this image is allocated 16GB memory. But after reducing memory to 8GB, oracle instance was not started.




1. Create pfile from spfile

cd $ORACLE_HOME/dbs

sqlplus / as sysdba

CREATE pfile='[PFILE_NAME]' from spfile='[SPFILE_NAME]'





2. Edit pfile

$> vi myinit.ora



3. Startup as pfile

$> sqlplus / as sysdba

startup pfile='[PFILE_NAME]';




4. Create sfpile from pfile

create spfile'spfile[INSTANCE_NAME].ora' from pfile'[PFILE_NAME]';


[JSON] How to skip serialize/deserialize variables using jackson annotation

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
public class JacksonTest {
 
 private String name = null;
 private int age = 0;
 private String[] emails = null;
 private java.util.List< String> favorites = null;
 private String mobile = null;
 private java.util.concurrent.BlockingQueue< String> concurrentQueue = null;
 
 public JacksonTest() {
 }
 
 public JacksonTest( String name, int age, String[] emails, java.util.List< String> favorites, String mobile) {
  this.name = name;
  this.age = age;
  this.emails = emails;
  this.favorites = favorites;
  this.mobile = mobile;
  
 }
 
 public String getName() {
  return name;
 }
 
 public int getAge() {
  return age;
 }
 
 public String[] getEmails() {
  return this.emails;
 }

 public void setEmails(String[] emails) {
  this.emails = emails;
 }
 

 public java.util.List<String> getFavorites() {
  return this.favorites;
 }

 public void setFavorites(java.util.List<String> favorites) {
  this.favorites = favorites;
 }
 

 public String getMobile() {
  return this.mobile;
 }

 public void setMobile(String mobile) {
  this.mobile = mobile;
 }
 

 public void setName(String name) {
  this.name = name;
 }
 

 public void setAge(int age) {
  this.age = age;
 }
 
 public void setConcurrentQueue( java.util.concurrent.BlockingQueue< String> concurrentQueue) {
  this.concurrentQueue = concurrentQueue;
 }
 
 public java.util.concurrent.BlockingQueue< String> getConcurrentQueue() {
  return this.concurrentQueue;
  
 }

 public static void main(String[] args) throws IOException {
  JacksonTest jackson = new JacksonTest( "dorbae", 27, new String[] { "jangsb89@gamil.com", "dorbae@nate.com"}, null, null );
  java.util.List< String> favorites = new java.util.ArrayList< String>();
  favorites.add( "programming");
  favorites.add( "data analytics");
  favorites.add( "data modeling");
  favorites.add( "swimming");
  jackson.setFavorites( favorites);
  
  JacksonTest jackson2 = null;
  
  // Object -> JSON
  com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
  String json = mapper.writeValueAsString( jackson);
  System.out.println( "======== Object -> JSON ========");
  System.out.printf( "%s\n\n", json);
  
  // JSON -> Object
  mapper = new ObjectMapper();
  jackson2 = mapper.readValue( json, JacksonTest.class);
  System.out.println( "======== JSON -> Object ========");
  System.out.printf( "name=%s, age=%d\n", jackson2.getName(), jackson2.getAge());
  
 }

}








 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    @JsonIgnore
 public void setConcurrentQueue( java.util.concurrent.BlockingQueue< String> concurrentQueue) {
  this.concurrentQueue = concurrentQueue;
 }
 
 @JsonIgnore
 public java.util.concurrent.BlockingQueue< String> getConcurrentQueue() {
  return this.concurrentQueue;
  
 }

[JSON] Convert object to json and convert json to object using Jackson

public class JacksonTest {
 
 private String name = null;
 private int age = 0;
 private String[] emails = null;
 private java.util.List< String> favorites = null;
 private String mobile = null;
 
 public JacksonTest() {
 }
 
 public JacksonTest( String name, int age, String[] emails, java.util.List< String> favorites, String mobile) {
  this.name = name;
  this.age = age;
  this.emails = emails;
  this.favorites = favorites;
  this.mobile = mobile;
  
 }
 
 public String getName() {
  return name;
 }
 
 public int getAge() {
  return age;
 }
 
 public String[] getEmails() {
  return this.emails;
 }

 public void setEmails(String[] emails) {
  this.emails = emails;
 }
 

 public java.util.List<String> getFavorites() {
  return this.favorites;
 }

 public void setFavorites(java.util.List<String> favorites) {
  this.favorites = favorites;
 }
 

 public String getMobile() {
  return this.mobile;
 }

 public void setMobile(String mobile) {
  this.mobile = mobile;
 }
 

 public void setName(String name) {
  this.name = name;
 }
 

 public void setAge(int age) {
  this.age = age;
 }
 

 public static void main(String[] args) throws IOException {
  JacksonTest jackson = new JacksonTest( "dorbae", 27, new String[] { "jangsb89@gamil.com", "dorbae@nate.com"}, null, null );
  java.util.List< String> favorites = new java.util.ArrayList< String>();
  favorites.add( "programming");
  favorites.add( "data analytics");
  favorites.add( "data modeling");
  favorites.add( "swimming");
  jackson.setFavorites( favorites);
  
  JacksonTest jackson2 = null;
  
  // Object -> JSON
  com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();
  String json = mapper.writeValueAsString( jackson);
  System.out.println( "======== Object -> JSON ========");
  System.out.printf( "%s\n\n", json);
  
  // JSON -> Object
  mapper = new ObjectMapper();
  jackson2 = mapper.readValue( json, JacksonTest.class);
  System.out.println( "======== JSON -> Object ========");
  System.out.printf( "name=%s, age=%d\n", jackson2.getName(), jackson2.getAge());
  
 }

}

Wednesday, 3 August 2016

[Java] How to make Concurrent Hash Set

Upper Java 1.8

java.util.Set< String> concurrentSet = java.util.concurrent.ConcurrentHashMap.newKeySet();

Lower Java 1.8

java.util.Set< String> concurrentSet = java.util.Collections.newSetFromMap( new java.util.concurrent.ConcurrentHashMap< String, Boolean>());

[DBMS] Table schema meta table (DBMS별 테이블 스키마 테이블)

DBMSTABLE
H2INFORMATION>SCHEMA.TABLES
DerbyDBSYS.SYSTABLES
JavaDBSYS.SYSTABLES
MySQLinformation_schema.TABLES
MariaDBinformation_schema.TABLES
OracleSYS.ALL_TABLES

H2

COLUMNDATA_TYPE
TABLE_CATALOGVARCHAR
TABLE_SCHEMAVARCHAR
TABLE_NAMEVARCHAR
TABLE_TYPEVARCHAR
STORAGE_TYPEVARCHAR
SQLVARCHAR
REMARKSVARCHAR
LAST_MODIFICATIONBIGINT
IDINTEGER
TYPE_NAMEVARCHAR
TABLE_CLASSVARCHAR

MySQL(MariaDB)

COLUMNDATA_TYPE
TABLE_CATALOGVARCHAR(512)
TABLE_SCHEMAVARCHAR(64)
TABLE_NAMEVARCHAR(64)
TABLE_TYPEVARCHAR(64)
ENGINEVARCHAR(64)
VERSIONBIGINT(21) unsigned
ROW_FORMATVARCHAR(10)
TABLE_ROWSBIGINT(21) unsigned
AVG_ROW_LENGTHBIGINT(21) unsigned
DATA_LENGTHBIGINT(21) unsigned
MAX_DATA_LENGTHBIGINT(21) unsigned
INDEX_LENGTHBIGINT(21) unsigned
DATA_FREEBIGINT(21) unsigned
AUTO_INCREMENTBIGINT(21) unsigned
CREATE_TIMEdatetime
UPDATE_TIMEdatetime
CHECK_TIMEdatetime
TABLE_COLLATIONVARCHAR(32)
CHECKSUMBIGINT(21) unsigned
CREATE_OPTIONSVARCHAR(255)
TABLE_COMMENTVARCHAR(2048)

[H2] How to run in server mode (H2 서버모드로 구동)

java -jar h2*.jar -webAllowOthers -tcpAllowOthers

Friday, 29 July 2016

[Eclipse] Favorite Plugins Software Sites

GEF releases
http://download.eclipse.org/tools/gef/updates/releases

Subversive
http://download.eclipse.org/technology/subversive/2.0/update-site

ER-Master
http://ermaster.sourceforge.net/update-site

Properties Editor
http://propedit.sourceforge.jp/eclipse/updates

PyDev
http://pydev.org/updates

Eclipse Color Theme
http://eclipse-color-theme.github.io/update/

Eclipse Class Decompiler
http://opensource.cpupk.com/decompiler/update/

More Clipboard
http://moreclipboard.sourceforge.net/updates/

Nebual Project (SWT Widget)
http://download.eclipse.org/nebula/snapshot/

Window Builder
Mars - http://download.eclipse.org/windowbuilder/WB/release/R201506241200-1/4.5/
Luna - http://download.eclipse.org/windowbuilder/WB/release/R201506241200-1/4.4/
Kepler - http://download.eclipse.org/windowbuilder/WB/release/R201406251200/4.3/

Monday, 25 July 2016

[CentOS] How to set up NTP client (NTP 클라이언트 설정)

NTP(Network Time Protocol)

NTP is network time protocol for maintaining correct system time. It can adjust the time according to a radio or atomic clock and can be tailored to the millisecond time (1/1000 second).

Basically, NTP has a hierarchical structure of stratum.
straum 0       : Equipment for calculating the time. Ex) GPS, CS(cesium) Atomic Clock
straum 1       : Server synchronizing the time from straum 1.
straum 2 ~ n : Time server.



Setup


1. Install packages

1
#> yum -y install ntp





2. Edit configuration file

#> vi /etc/ntp.conf




3. Register NTP service

#> chkconfig ntpd on
#> chkconfig --list | grep ntpd




4. Start NTP service

#> service ntpd start

Friday, 22 July 2016

[ActiveMQ] Broker configuration and Client Sample using ScheduledMessage (스케줄링 메시지를 위한 브로커 설정 및 클라이언트 샘플)

ActiveMQ from version 5.4 has an optional persistent scheduler built into the ActiveMQ message broker. It is enabled by setting the broker schedulerSupport attribute to true in the Xml Configuration.

<broker xmlns="http://activemq.apache.org/schema/core" brokerName="DorbaeBroker" useJmx="true" schedulerSupport="true">

.
.
.

</broker>


Schedule Properties 

Property nameTypeDescription
AMQ_SCHEDULED_DELAYlongThe time in milliseconds that a message will wait before being scheduled to be delivered by the broker
AMQ_SCHEDULED_PERIODlongThe time in milliseconds to wait after the start time to wait before scheduling the message again
AMQ_SCHEDULED_REPEATintIf set period, the number of times to repeat scheduling a message for delivery.
Total message count = 1 + repeat

If set cron, the number of message repeat when execute cron 
AMQ_SCHEDULED_CRONStringUse a Cron entry to set the schedule

※ Be careful
If set AMQ_SCHEDULED_PERIOD, AMQ_SCHEDULED_REPEAT is the number of times to repeat scheduling a message for delivery.
(Total message count = 1 + repeat)

If set AMQ_SCHEDULED_CRON, AMQ_SCHEDULED_REPEAT is the number of times to repeat send message per 1 execution.
For example, you set
AMQ_SCHEDULED_REPEAT = 5
AMQ_SCHEDULED_CRON = * * * * *

6(1+5) messages are sent in destination per minute.


Client Sample

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
package pe.dorbae.test.jms.activemq;

import java.util.Properties;

/*
 * ************************************************************************************
 *
 * ScheduledMessage.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2016-07-22 dorbae Initialize
 * @since 2016-07-22
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class TestScheduledMessage {

 public TestScheduledMessage() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  String jmsFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory";
  String connectionFactoryName = "ConnectionFactory";
  String jmsUrl = "tcp://localhost:61616";
  String clientId= "iSharkClient.Test.ScheduledMessage";
  String queueName = "DORBAE.TEST";

  Properties jmsProps = new Properties();
  jmsProps.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY, jmsFactory); 
  jmsProps.put( javax.naming.Context.PROVIDER_URL, jmsUrl);
  
  javax.naming.InitialContext jndi = null;
  javax.jms.ConnectionFactory connectionFactory = null;
  javax.jms.Connection conn = null;
  javax.jms.Session session = null;
  javax.jms.Destination destination = null;
  javax.jms.Message message = null;
  javax.jms.MessageProducer producer = null;
  
  try {
   jndi = new javax.naming.InitialContext( jmsProps);
   connectionFactory = ( javax.jms.ConnectionFactory)jndi.lookup( connectionFactoryName);
   conn = connectionFactory.createConnection();
   conn.setClientID( clientId);
   session = conn.createSession( false, javax.jms.Session.AUTO_ACKNOWLEDGE); // Not Transacted
   destination = session.createQueue( queueName);
   producer = session.createProducer( destination);
   message = session.createTextMessage( "http://dorbae.blogspot.com");
   
   /*
    * For Delay Message
    * 
    * Message will be sent to destination after delay times
    *  
    * 
   long delayTime = 60L * 1000L; // 1 Minute
   message.setLongProperty( org.apache.activemq.ScheduledMessage.AMQ_SCHEDULED_DELAY, delayTime);
    *
    */
   
   /*
    * For Period Repeat
    * 
    * Repeated messages will be sent to destination waiting period times between each re-delivery 
    * 
   long period = 10L * 1000L;
   int repeat = 5;
   message.setLongProperty( org.apache.activemq.ScheduledMessage.AMQ_SCHEDULED_PERIOD, period);
   message.setIntProperty( org.apache.activemq.ScheduledMessage.AMQ_SCHEDULED_REPEAT, repeat);
    *
    */
   
   /*
    * For Cron
    * 
    * Message will be sent to destination according as cron pattern 
    *
    */
   message.setStringProperty( org.apache.activemq.ScheduledMessage.AMQ_SCHEDULED_CRON, "0 * * * *");
   
   producer.send( message);
   
  } catch ( Exception e) {
   e.printStackTrace();
   
  } finally {
   if ( session != null)
    try {
     session.close();
    } catch ( Exception e) {}
   
   if ( conn != null)
    try {
     conn.close();
    } catch ( Exception e) {}
  }
 }

}

ScheduledMessage.AMQ_SCHEDULED_CRONAMQ_SCHEDULED_CRON
ScheduledMessage.AMQ_SCHEDULED_DELAYAMQ_SCHEDULED_DELAY
ScheduledMessage.AMQ_SCHEDULED_IDscheduledJobId
ScheduledMessage.AMQ_SCHEDULED_PERIODAMQ_SCHEDULED_PERIOD
ScheduledMessage.AMQ_SCHEDULED_REPEATAMQ_SCHEDULED_REPEAT
ScheduledMessage.AMQ_SCHEDULER_ACTIONAMQ_SCHEDULER_ACTION
ScheduledMessage.AMQ_SCHEDULER_ACTION_BROWSEBROWSE
ScheduledMessage.AMQ_SCHEDULER_ACTION_END_TIMEACTION_END_TIME
ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEREMOVE
ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALLREMOVEALL
ScheduledMessage.AMQ_SCHEDULER_ACTION_START_TIMEACTION_START_TIME
ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION ActiveMQ.Scheduler.Management

※ Be careful
The message property scheduledJobId is reserved for use by the Job Scheduler. If this property is set before sending, the message will be sent immediately and not scheduled. Also, after a scheduled message is received, the property scheduledJobId will be set on the received message so keep this in mind if using something like a Camel Route which might automatically copy properties over when re-sending a message.





A Scheduled message is canceled only using JMX unfortunately. There's an open issue to support rescheduling.






Tuesday, 12 July 2016

[JDBC] java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occuring

JDBC-ODBC Bridge has been removed since Java 8. If you want to use JDBC-ODBC driver, you should run on below Java 7. If had been used JDBC-ODBC driver for interfacing with  Microsoft Access database, you can use 'UCanAccess' library that is open-source pure java JDBC driver.

http://ucanaccess.sourceforge.net/site.html

Monday, 4 July 2016

[Maria/MySQL] How to allow remote client access database (원격 접속 허용 설정)

1. Connect database as root

#> mysql -uroot -p






2. Check current status

SELECT host FROM mysql.user WHERE user='[USER_NAME]';





3. Add remote authority

INSERT INTO mysql.user (host,user,password) VALUES ('[Allowed IP]', '[USER_NAME]', password('[PASSWORD]'));

GRANT ALL PRIVILEGES ON *.* TO '[USER_NAME]'@'[Allowed IP]';
FLUSH PRIVILEGES;