Just an another blog about software development, configuration and usual stuff ...

Create Calendar Resource using Google Data Java API (gdata-java-client)

Many enterprises and educational units want to track of their resources like conference rooms, projectors, etc. This is very important from enterprise point of view. Luckily Google introduced Calendar Resources in Premier and Education Edition.

The question comes how to manage resources from API. Calendar Resource Management at Google explains this, however not in java.

Following is the code snippet which shows how to create resources using Java GData client API.

try {
  String application_name = "APPLCATION_NAME";
  String admin_email = "APPS_ADMIN_EMAIL";
  String admin_password = "APPS_ADMIN_PASSWORD";
  String domain_name = "APPS_DOMAIN_NAME";
  
  AppsPropertyService service = new AppsPropertyService(application_name);
  service.setUserCredentials(admin_email,admin_password));

  URL feedUrl = 
    new URL("https://apps-apis.google.com/a/feeds/calendar/resource/2.0/" + domain_name);

  GenericEntry resourceEntry = new GenericEntry();
  resourceEntry.declareExtensions(service.getExtensionProfile());
  resourceEntry.addProperty("resourceId", "CAL_RESOURCE_ID");
  resourceEntry.addProperty("resourceCommonName", "CAL_RESOURCE_COMMON_NAME");
  resourceEntry.addProperty("resourceDescription", "CAL_RESOURCE_DESC");
  resourceEntry.addProperty("resourceType", "CAL_RESOURCE_TYPE");
  
  service.insert(feedUrl, resourceEntry);

  resourceEntry = null;
  feedUrl = null;
  service = null;
} catch (MalformedURLException ex) {
  ex.printStackTrace();
} catch(AuthenticationException ex) {
  ex.printStackTrace();
} catch (AppsForYourDomainException ex) {
  ex.printStackTrace();
} catch (IOException ex) {
  ex.printStackTrace();
} catch (ServiceException ex) {
  ex.printStackTrace();
}

| More

"Invalid Java Home" Error when installing Oracle JDeveloper 11g on OS X 10.6

To install Oracle JDeveloper 11g on Mac OS X 10.6, go to Oracle website or google search and download JDeveloper 11g Studio Edition. Choose "Base Install For all the platforms (without JDK 6)" in the table.

To start installation, launch Terminal, go to downloaded folder and run

java -jar jdevstudio11113install.jar

Now you will see that the installer is trying to extract some files. After full extraction, you will see installation wizard. Select appropriate options and click on "Next" in several screen. After two or three screen, you will see following where it does not find default JDK.


As we all know that the JDK path in OS X is /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home. So if you click on "Browse..." and select that path, you will get "Invalid Java Home" error.


JDeveloper installation can not find proper JDK.

Solution:


Exit the installation wizard and perform following steps:

cd /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
sudo mkdir jre
cd jre
sudo mkdir lib
cd lib
sudo ln -s ../../../Classes/classes.jar rt.jar

Restart the installation and now you will see that it finds the proper JDK.


Now you can finish the installation.

You can do the same thing, if you find the same type of error while running JDeveloper from Base Editon.

| More

MySQL Query Log (Enable general logging)

When you are developing any application with database, it is very helpful to have log of all database queries. This is also helpful if you use any ORM (Object Relational Mapping) tool. By looking at query log, you can actually see which queries are being executed against the database, how long they perform to fetch results, etc. This information will help developers to write better database queries.

I have searched across web about how to enable general query logging in MySQL. There are many resources on that topic but it takes a little effort to find an exact answer. Even MySQL documentation is not that helpful. So here is the straight forward answer to that question. I am using my.cnf in this configuration.

Open my.cnf and add following lines:

general_log = 1 
log_output = TABLE 

Here we are using MySQL table for all general logs. If you want to use a file, please use the following settings instead. Also make sure that the user under which MySQL server is running has write access to log file.

general_log = 1
log_output = FILE
general_log_file = /full/path/to/general_log.log

Now we need to create table in MySQL database for general logging. Please login to MySQL database root and using following SQL commands create general_log table if it does not exist.

CREATE TABLE `general_log` (
  `event_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_host` mediumtext NOT NULL,
  `thread_id` int(11) NOT NULL,
  `server_id` int(11) NOT NULL,
  `command_type` varchar(64) NOT NULL,
  `argument` mediumtext NOT NULL
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'

Now restart the MySQL server to enable all changes. If you don’t want to restart the server and apply changes, execute following commands in MySQL shell,

SET GLOBAL log_output='TABLE'; 
SET GLOBAL general_log='ON';

Note: If you want to use file based logging, use log_output = ‘FILE’ instead.

Execute few queries and let the server run for some times. Then login to MySQL server and run select queries on general_log table. You will find many helpful information here. You can also extract query data to file and analyze it.

If you have any suggestion, please let me know.

| More

Archives

Categories