Created
January 7, 2016 07:42
-
-
Save ebuildy/e0dbdaa463e07576043c to your computer and use it in GitHub Desktop.
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 com.zaxxer.hikari.HikariDataSource; | |
import org.apache.hadoop.hbase.thrift.generated.BatchMutation; | |
import java.sql.Connection; | |
import java.sql.PreparedStatement; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.util.ArrayList; | |
public class Test | |
{ | |
private Connection connection; | |
public static void main(String [] args) | |
{ | |
HikariDataSource ds = new HikariDataSource(); | |
ds.setJdbcUrl("jdbc:phoenix:zookeeper"); | |
ds.setDriverClassName("org.apache.phoenix.jdbc.PhoenixDriver"); | |
ds.setAutoCommit(false); | |
try { | |
this.connection = ds.getConnection(); | |
System.out.println("Connection is valid: " + this.connection.isValid(10)); | |
} | |
catch(SQLException e) | |
{ | |
e.printStackTrace(); | |
} | |
try { | |
PreparedStatement statement = this.connection.prepareStatement("UPSERT INTO \"events\"(\"uuid\",\"event\") VALUES(?, ?)"); | |
statement.setString(1, "toto"); | |
statement.setString(2, "click"); | |
statement.executeUpdate(); | |
this.connection.commit(); | |
this.connection.close(); | |
} catch (SQLException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment