Commit cfb09aea authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading
+7 −0
Changes for Learning Presto DB - Working Files/Chapter 1/No Work Files.rtf: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf350
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural

\f0\fs24 \cf0 No work files for this lesson...}
 No newline at end of file
+28 −0
Changes for Learning Presto DB - Working Files/Chapter 10/JDBC/JdbcDemo.java: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo {

    public static void main(String[] args) throws Exception {
	Class.forName("com.facebook.presto.jdbc.PrestoDriver");

	//String url = "jdbc:presto://localhost:8181";
	//String url = "jdbc:presto://localhost:8181/tpch";
	String url = "jdbc:presto://localhost:8181/tpch/sf1";

        Connection connection = DriverManager.getConnection(url, "hive", "");
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("select * from tpch.tiny.region");

        while (rs.next()) {
            System.out.print(rs.getInt(1) + ", " + rs.getString(2) + ", " + rs.getString(3));
            System.out.println();
        }
        rs.close();

        statement.close();
        connection.close();
    }
}
+3 −0
Changes for Learning Presto DB - Working Files/Chapter 10/JDBC/Using JDBC.sh: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
wget https://repo1.maven.org/maven2/com/facebook/presto/presto-jdbc/0.150/presto-jdbc-0.150.jar
javac JdbcDemo.java
java -cp presto-jdbc-0.150.jar:. JdbcDemo
+35 −0
Changes for Learning Presto DB - Working Files/Chapter 10/ODBC on Linux/ODBC on Linux.txt: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line

# 1. Download unixODBC Driver Manager from: http://www.unixodbc.org/
# 2. Extract: tar xvzf unixODBC*.tar
# 3. Build
#    ./configure
#    make
#    sudo make install


# 4. Set env variables
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/odbc:/opt/teradata/prestoodbc/lib/64
# OR (depending on your Linux distribution)
# export LD_LIBRARY_PATH=/usr/lib64/:/opt/teradata/prestoodbc/lib/64

export ODBCINI=/opt/teradata/prestoodbc/Setup/odbc.ini
export SIMBAINI=/opt/teradata/prestoodbc/lib/64/teradata.prestoodbc.ini
export ODBCSYSINI=/opt/teradata/prestoodbc/Setup/

# 5. Connect to Presto using ODBC via isql
$ /usr/local/bin/isql -v PrestoDSN

# You should see something like this:
#
#SQL> [ec2-user@ip-172-31-15-74 Setup]$ /usr/local/bin/isql -v PrestoDSN
#+---------------------------------------+
#| Connected!                            |
#|                                       |
#| sql-statement                         |
#| help [tablename]                      |
b#| quit                                  |
#|                                       |
#+---------------------------------------+
#SQL> 

# Make sure to not put ";" after your queries. This tool does not require them
+35 −0
Changes for Learning Presto DB - Working Files/Chapter 10/ODBC on Linux/odbc.ini: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
[ODBC]
Trace=no

[ODBC Data Sources]
Teradata Presto DSN 64=Teradata Presto ODBC Driver 64-bit

[PrestoDSN]
# This key is not necessary and is only to give a description of the data source.
Description=Teradata Presto ODBC Driver (64-bit) DSN

# Driver: The location where the ODBC driver is installed to.
Driver=/opt/teradata/prestoodbc/lib/64/libteradataprestoodbc64.so

# Required: These values can also be specified in the connection string.
# Host name of he Presto server.

Host=localhost
# The listen port of the Presto server.
Port=8080

# Optional: These values can also be specified in the connection string.
# The user ID to use for the connection. (Optional)
UID=hdfs

# The authentication type to use for the connection. (Optional. Default: No Authentication)
#   No Authentication
#   Kerberos Authentication
AuthenticationType=No Authentication

# The presto catalog for the connection. (Optional)
Catalog=tpch
schema=sf1

# The time zone use for the connection. (Optional. Default: Current time zone of the OS)
TimeZoneID=
Loading