Package net.snowflake.ingest.example
Class IngestExampleHelper
- java.lang.Object
-
- net.snowflake.ingest.example.IngestExampleHelper
-
public class IngestExampleHelper extends Object
Helper methods to connect to snowflake jdbc and run queries Created by vganesh on 5/19/17.
-
-
Constructor Summary
Constructors Constructor Description IngestExampleHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Path
createTempCsv(String directoryPath, String filename, int rows)
static void
doQuery(Connection conn, String query)
Try to execute a SQL query and throw if it failsstatic KeyPair
generateKeyPair()
Generates an RSA keypair for use in this teststatic Connection
getConnection(String user, String password, String account, String host, int port)
static String
getPublicKeyString(KeyPair keypair)
Generate the public key as a stringstatic void
makeLocalDirectory(String directoryPath)
Create directories if they don't exist under directoryPath.static void
makeSampleFile(String directoryPath, String filename)
Create file under directoryPath with fileName and populate it with test data
-
-
-
Method Detail
-
makeLocalDirectory
public static void makeLocalDirectory(String directoryPath) throws IOException
Create directories if they don't exist under directoryPath.- Parameters:
directoryPath
-- Throws:
IOException
-
createTempCsv
public static Path createTempCsv(String directoryPath, String filename, int rows) throws IOException
- Throws:
IOException
-
makeSampleFile
public static void makeSampleFile(String directoryPath, String filename) throws IOException
Create file under directoryPath with fileName and populate it with test data- Parameters:
directoryPath
-filename
-- Throws:
IOException
-
getConnection
public static Connection getConnection(String user, String password, String account, String host, int port) throws Exception
- Throws:
Exception
-
doQuery
public static void doQuery(Connection conn, String query)
Try to execute a SQL query and throw if it fails- Parameters:
query
- the query in question
-
generateKeyPair
public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException
Generates an RSA keypair for use in this test- Returns:
- a valid RSA keypair
- Throws:
NoSuchAlgorithmException
- if we don't have an RSA algoNoSuchProviderException
- if we can't use SHA1PRNG for randomization
-
getPublicKeyString
public static String getPublicKeyString(KeyPair keypair) throws NoSuchAlgorithmException, InvalidKeySpecException
Generate the public key as a string- Returns:
- the public key as a string
- Throws:
NoSuchAlgorithmException
InvalidKeySpecException
-
-