Wednesday, December 18, 2013

Whenever you select a negative value from MySQL table, "-" will become a part of the field name returned in a result set. For example, we have following statement:selectid fromMY_TABLE;It will return a result with field name "id".

select -id fromMY_TABLE;
will return a result with field name "-id".

select -custom.id fromMY_TABLE custom;
will also include table alias name and return a result with field name "-custom.id".

In such case you should use "as %FIELD_NAME%" to be sure that you will have same field name:

Monday, July 15, 2013

Sometimes you can put command line parameters in wrong order, and have a file name starting with "--" as a result. If you'll try to use rm<file name> it will fail because it will assume that you are providing a flag to rm command.In this case, use following command:

One of common problem with NFS mounts is "permission denied" error while trying to modify existing files and folders, even if your user and group names are matching content creator's user and group. If you're sure that you gave "rw" permission on this NFS share to the client's host, check each user ID and group ID. File access permissions are being verified based on UID and GID, not on names. Run these commands on both machines, and check that UID and GID are matching:/usr/sbin/vipw -s/usr/sbin/vigr -sIf UID or GID is different, change it on one of servers using following commands:

/usr/sbin/usermod -u {NEW_USER_ID}{USER_NAME}

/usr/sbin/groupmod -g {NEW_GROUP_ID}{GROUP_NAME}

/usr/sbin/usermod -g {NEW_GROUP_ID}{USER_NAME}

For example, you need to update UID of user "test" to 345, GID of group "testgrp" to 999:

/usr/sbin/usermod -u 345 test

/usr/sbin/groupmod -g 999 testgrp

/usr/sbin/usermod -g 999 test

First command will update UID, second will update GID, third will update GID in user record.

NOTE: all these commands should be executed as root

NOTE 2: if you have any folders owned by this user (except home folder), you'll need to change ownership to same user and group again, because it also uses UID and GID.

Monday, May 13, 2013

This Exception usually comes up when you are using IMAP protocol, and calling part.getDisposition() method. It's a known bug of several IMAP servers. I had this error in GMail when I tried to parse a message with attached .eml file.If you are facing this issue, create a new MimeMessage based on the one that you're trying to parse. This will force Javamail to download and parse the Mime message locally, and in most cases, it will fix your problem.Keep the original message, because you still need it to set flags on server (to delete it, for example).You can do something like this:

public void processMimeMessage(MimeMessage msg) throws MessagingException
{try{//some processing}catch(MessagingException messEx){//making sure that it's a BODYSTRUCTURE errorif(messEx.getMessage()!=null&& messEx.getMessage().toLowerCase().
contains("unable to load "+"bodystructure")){//creating local copy of given MimeMessage
MimeMessage msgDownloaded =new MimeMessage((MimeMessage) msg);//calling same method with local copy of given MimeMessage
processMimeMessage(msgDownloaded);}else{throw messEx;}}}