SELECT * FROM INFORMATION_SCHEMA.LOCKS; SELECT * FROM INFORMATION_SCHEMA.LOCKS WHERE TABLE_SCHEMA = '<SCHEMA_NAME>' AND TABLE_NAME = '<TABLE_NAME>' ;
Tuesday, 30 August 2016
[H2] How to check table lock in H2 database
Monday, 29 August 2016
[NodeMCU] Lua Crypto Package and interface with Java program using AES-ECB
NodeMCU is an eLua based firmware for the ESP8266 WiFi SOC from Espressif.
NodeMCU support encrypt and decrypt functions which are in crypto packages.
http://nodemcu.readthedocs.io/en/dev/en/modules/crypto/
This is manual for Crypto package.
w9kOL6y40iVqhuGdWt6vLw==
NodeMCU support encrypt and decrypt functions which are in crypto packages.
http://nodemcu.readthedocs.io/en/dev/en/modules/crypto/
This is manual for Crypto package.
crypto.encrypt()
Encrypts Lua strings.
Syntax
crypto.encrypt(algo, key, plain [, iv])
Parameters
algo
the name of the encryption algorithm to use, one of"AES-ECB"
for 128-bit AES in ECB mode"AES-CBC"
for 128-bit AES in CBC mode
key
the encryption key as a string; for AES encryption this MUST be 16 bytes longplain
the string to encrypt; it will be automatically zero-padded to a 16-byte boundary if necessaryiv
the initilization vector, if using AES-CBC; defaults to all-zero if not given
Returns
The encrypted data as a binary string. For AES this is always a multiple of 16 bytes in length.
Crypto package AES-ECB using no padding. So you should make 16 multiple bytes array from plain text. And NodeMCU use EUCKR encoding in crypto package.NodeMCU
1 2 3 4 5 6 | key = "1234567890abcdef" cipher = crypto.encrypt("AES-ECB", key, "Hi, I'm secret!") print(crypto.toBase64(cipher)) cipher = crypto.encrypt("AES-ECB", key, "가나다라마바사") print(crypto.toBase64(cipher)) |
Result
LQ95s23+t6PK0mmokJFSYg==w9kOL6y40iVqhuGdWt6vLw==
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public static void main( String[] args) throws Exception { String keyValue = "1234567890abcdef"; String encryptedText1 = "LQ95s23+t6PK0mmokJFSYg=="; String encryptedText2 = "w9kOL6y40iVqhuGdWt6vLw=="; java.nio.charset.Charset charset = java.nio.charset.Charset.forName( "euckr"); java.security.Key key = new javax.crypto.spec.SecretKeySpec( keyValue.getBytes( charset), "AES"); javax.crypto.Cipher cipher = Cipher.getInstance( "AES/ECB/NoPadding"); cipher.init( Cipher.DECRYPT_MODE, key); System.out.println( "DecryptedText1=" + new String( cipher.doFinal( org.apache.commons.codec.binary.Base64.decodeBase64( encryptedText1.getBytes( charset))), charset)); System.out.println( "DecryptedText2=" + new String( cipher.doFinal( org.apache.commons.codec.binary.Base64.decodeBase64( encryptedText2.getBytes( charset))), charset)); } |
Result
Wednesday, 24 August 2016
[CentOS] Setup Mail server (메일 서버 구축)
MTA (Mail Transfer Agent)
ex) Sendmail, Qmail, Microsfot Exchange
MUA (Mail user Agent)
ex) Outlook Express
MDA (Mail Delivery Agent)
ex) POP3, IMAP
Send Protocol
SMTP (Simple Mail Transfer Protocol)
: TCP/IP mail transfer protocol. Default port 25.
Remove 'dnl' command
Cwlocalhost ->Cw[MAIL_SERVER_DOMAIL]
ex) Sendmail, Qmail, Microsfot Exchange
MUA (Mail user Agent)
ex) Outlook Express
MDA (Mail Delivery Agent)
ex) POP3, IMAP
Send Protocol
SMTP (Simple Mail Transfer Protocol)
: TCP/IP mail transfer protocol. Default port 25.
1. Install Sendmail packages
# yum -y install sendmail*
2. Configure SMTP
# vi /etc/mail/sendmail.mc
Remove 'dnl' command
# m4 /etc/mail/sendmail.mc > /ect/mail/sendmail.cf # vi /etc/mail/snedmail.cf
Cwlocalhost ->Cw[MAIL_SERVER_DOMAIL]
127.0.0.1 (Internal Mail Server) -> 0.0.0.0
3. Configure Mail Access
# vi /ect/mail/access
# makemap hash /etc/mail/access < /etc/mail/access
# vi /etc/mail/local-host-names
4. SASL security module
# service saslauthd start # chkconfig saslauthd on # init 6
5. Disable Firewall
# service iptables stop # chkconfig --level 345 iptables off # vi /etc/selinux/config # getenforce
# service iptables status
6. Install Dovecot packages
# yum -y install dovecot
7. Configure Dovecot
# vi /etc/dovecot/dovecot.conf
# vi /etc/dovecot/conf.d/10-mail.conf
# vi /etc/dovecot/conf.d/10-ssl.conf
# vi /etc/dovecot/conf.d/10-auth.conf
8. Start Dovecot
# service dovecot start # chkconfig dovecot on
[Java] Convert Hexadeciamal to IP address
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | public static String convertHex2IP( String hex) throws UnknownHostException { java.net.InetAddress address = java.net.InetAddress.getByAddress( javax.xml.bind.DatatypeConverter.parseHexBinary( hex)); return address.getHostAddress(); } public static String convertIP2Hex( String ip) throws UnknownHostException { java.net.InetAddress address = java.net.InetAddress.getByName( ip); byte[] bytes = address.getAddress(); StringBuilder sb = new StringBuilder(); for ( int ll = 0; ll < bytes.length; ll++) sb.append( String.format( "%02X", bytes[ ll])); return sb.toString(); } |
[Java] How to ping IP address in java (자바에서 Ping 구현)
1 2 3 4 5 | public static boolean ping( String host, int milisecondTimeout) throws UnknownHostException, IOException { java.net.InetAddress address = InetAddress.getByName( host); return address.isReachable( milisecondTimeout); } |
Friday, 19 August 2016
[RCP] java.lang.ClassCastException: org.eclipse.nebula.widgets.pshelf.PShelf cannot be cast to org.eclise.nebula.widgets.pshelf.PShelf in WindowBuilder when using Nebula PShelf Widget
Wednesday, 17 August 2016
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)
[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별 테이블 스키마 테이블)
DBMS | TABLE |
H2 | INFORMATION>SCHEMA.TABLES |
DerbyDB | SYS.SYSTABLES |
JavaDB | SYS.SYSTABLES |
MySQL | information_schema.TABLES |
MariaDB | information_schema.TABLES |
Oracle | SYS.ALL_TABLES |
H2
COLUMN | DATA_TYPE |
TABLE_CATALOG | VARCHAR |
TABLE_SCHEMA | VARCHAR |
TABLE_NAME | VARCHAR |
TABLE_TYPE | VARCHAR |
STORAGE_TYPE | VARCHAR |
SQL | VARCHAR |
REMARKS | VARCHAR |
LAST_MODIFICATION | BIGINT |
ID | INTEGER |
TYPE_NAME | VARCHAR |
TABLE_CLASS | VARCHAR |
MySQL(MariaDB)
COLUMN | DATA_TYPE |
TABLE_CATALOG | VARCHAR(512) |
TABLE_SCHEMA | VARCHAR(64) |
TABLE_NAME | VARCHAR(64) |
TABLE_TYPE | VARCHAR(64) |
ENGINE | VARCHAR(64) |
VERSION | BIGINT(21) unsigned |
ROW_FORMAT | VARCHAR(10) |
TABLE_ROWS | BIGINT(21) unsigned |
AVG_ROW_LENGTH | BIGINT(21) unsigned |
DATA_LENGTH | BIGINT(21) unsigned |
MAX_DATA_LENGTH | BIGINT(21) unsigned |
INDEX_LENGTH | BIGINT(21) unsigned |
DATA_FREE | BIGINT(21) unsigned |
AUTO_INCREMENT | BIGINT(21) unsigned |
CREATE_TIME | datetime |
UPDATE_TIME | datetime |
CHECK_TIME | datetime |
TABLE_COLLATION | VARCHAR(32) |
CHECKSUM | BIGINT(21) unsigned |
CREATE_OPTIONS | VARCHAR(255) |
TABLE_COMMENT | VARCHAR(2048) |
Subscribe to:
Posts (Atom)