Wednesday, September 25, 2013

Cassandra frequently used CQLs

Some of the commonly used Cassandra CQLs

1. List all the keyspaces in Cassandra
use system;
select * from schema_keyspaces;

2. List all the tables in a keyspace
use {keyspace_name};
describe tables;

3. How to dump CQL output on to a file
{cassandra_home}/bin/cqlsh -f cquery.txt > cquery.out

Link to an exhaustive list of CQL query examples
http://cassandra.apache.org/doc/cql/CQL.html

Below is the snip of how the CShell would look like

Tuesday, September 24, 2013

Load a resource file in Java

Read a resource file from a web application
new PropertyConfigurator().getClass().getClassLoader().getResourceAsStream("file.properties")

Sunday, September 15, 2013

Java Official Tutorial Page

Where to start learning about Java?
http://docs.oracle.com/javase/tutorial/tutorialLearningPaths.html

Java Memory Management
http://www.oracle.com/technetwork/java/javase/memorymanagement-whitepaper-150215.pdf

Saturday, September 14, 2013

Java Interview!!

Couple of links that I came across to prep for the Java Interview
http://stackoverflow.com/questions/2114212/questions-every-good-java-java-ee-developer-should-be-able-to-answer
http://www.techinterviews.com/interview-questions/java
http://programmers.stackexchange.com/questions/58113/how-to-interview-a-j2ee-developer
http://javarevisited.blogspot.in/2011/09/servlet-interview-questions-answers.html
http://www.javagyan.com/preparing-for-an-interview/java-j2ee-interview-questions

java.util.String

What is the o/p of the code blocks below and why is the difference in o/p's?
  String helloWorld = "Hello, world!";
  if(helloWorld=="Hello, world!"){
   System.out.println("== is true");
  }else{
   System.out.println("== is false");
  }
  
  if(helloWorld.equals("Hello, world!")){
   System.out.println(".equals is true");
  }else{
   System.out.println(".equals is false");
  }

  String helloWorld = new String("Hello, world!");
  if(helloWorld=="Hello, world!"){
   System.out.println("== is true");
  }else{
   System.out.println("== is false");
  }
  
  if(helloWorld.equals("Hello, world!")){
   System.out.println(".equals is true");
  }else{
   System.out.println(".equals is false");
  }

Wednesday, September 11, 2013

Adding code syntax highlighter to your blog post!

Click me to know how to add code snippets to your blog like below!  
public class HelloWorld {
 public static void main(String[] args) {
  System.out.println("Hello, World!");
 }
}