Category Archives: Uncategorized
Eclipse shortcut ‘public static void main(String args[])’
type main + ctrl + spaceĀ
Sanitizing a byte steam in Java
private InputStream sanitizeStream(InputStream in) throws IOException{ BufferedInputStream bis = new BufferedInputStream(in); OutputStream output = new ByteArrayOutputStream(); //Sanitize input stream int ch; while ((ch = bis.read()) != -1) { if ((ch == 0x9) || (ch == 0xA) || (ch == 0xD) || ((ch >= 0x20) && (ch = 0xE000) && (ch = 0x10000) && (ch <= 0x10FFFF))) { output.write((int) ch); } } InputStream decodedInput = new ByteArrayInputStream( ((ByteArrayOutputStream) output).toByteArray()); return decodedInput; }
Write CQL output to a file
1. Create a file (say cquery.txt) with any cassandra queries.. For ex. given below
use system; select * from schema_keyspaces;
2. Run either of the following commands to achieve desired output
<cassandra_home>/bin/cqlsh -f cquery.txt > cquery.out <cassandra_home>/bin/cqlsh --file=cquery.txt > cquery.out
How to list all the key spaces in Cassandra?
use system;
select * from schema_keyspaces;
How to list all the tables in a key space in Cassandra?
Its as simple as these 2 steps
1. use <keyspace_name>; 2. describe tables;
Installing OJDBC jar to local maven repository
1. Command to install ojdbc jar to local maven repository
mvn install:install-file -Dfile={path/to/your/ojdbc.jar} -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.3.0 -Dpackaging=jar
2. Maven dependency to be added to the pom.xml
<dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version> </dependency>
Maven Integration for Eclipse JDK Warning
Things to be done to fix the problem
1. Add the following vm argument in the eclipse.ini
Note: This argument should be added before any of the vmargs -vm C:/path/to/jdk/bin/javaw.exe
2. Change the Installed JREs to point to a JDK instance on your eclipse
Goto Window -> Preferences -> Java -> Installed JREs
Select the intalled JRE and click edit to point to a JDK home directory
JCP – Java Community Web Site
JCP stands for Java Community Process. This website is a one shop stop to all JSR (Java Specification Requests). Each and every new Java API is born here!