This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jdbc.test; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import static java.lang.String.format; | |
public class Insert { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.AbstractMap; | |
import java.util.Arrays; | |
import java.util.Collections; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.LinkedHashMap; | |
import java.util.LinkedHashSet; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.Set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This file shoule be copied to src/java/ and executed from this directory | |
JARS=../../jars | |
CP=$JARS/hive-service-1.2.1.jar:$JARS/hive-jdbc-1.2.1.jar:$JARS/commons-logging-1.1.3.jar:$JARS/libthrift-0.9.3.jar | |
javac -cp $CP org/apache/hive/jdbc/HiveStatement.java | |
javac -cp $CP org/apache/hive/jdbc/HivePreparedStatement.java | |
javac -cp $CP org/apache/hive/jdbc/HiveResultSetMetaData.java | |
cp $JARS/hive-jdbc-1.2.1.jar $JARS/hive-jdbc-1.2.1_patch.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package visitor; | |
public class Book implements Visitable { | |
private final String title; | |
private final int pageCount; | |
public Book(String title, int pageCount) { | |
this.title = title; | |
this.pageCount = pageCount; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> | |
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script> | |
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script> | |
<script src='http:/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Action {ONE, TWO, THREE} | |
// .......... | |
Action a = ... | |
switch (a) { | |
case ONE: one(); break; | |
case TWO: two(); break; | |
case THREE: three(); break; | |
default: throw new UnsupportedOperationException(String.format("Operation %s is not supported", a)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Color { | |
RED, GREEN, BLUE,; | |
static { | |
Mirror.of(RGB.class); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public java.lang.String toString() { | |
#if ( $members.size() > 0 ) | |
#set ( $i = 0 ) | |
return String.format("$classname{#foreach( $member in $members )$member.name=%s#if ( $i < $members.size() - 1 ), #end#set ( $i = $i + 1 )#end}"#foreach( $member in $members ),#if ( $member.objectArray )$member.accessor == null ? null : java.util.Arrays.asList($member.accessor)#else$member.accessor#end#end); | |
#else | |
return "$classname{}"; | |
#end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TryPerf { | |
private static int foo(int a) { | |
return a * 2; | |
} | |
private static int tryFinally(int a) { | |
try { | |
return a * 2; | |
} finally { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Formatter; | |
public class FormatterExercise { | |
private static int n = 1_000_000; | |
public static void main(String[] args) throws InterruptedException { | |
long before = System.nanoTime(); | |
str(); | |
long after = System.nanoTime(); | |
System.out.println((after - before)/1_000_000); |