Created
April 20, 2020 13:02
-
-
Save naren-dremio/cfa0de4ad892b3768bb6e3eebb877644 to your computer and use it in GitHub Desktop.
JDBC example for Dremio
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
// Requires JDK 1.8 | |
// Run it with: | |
// javac Main.java && java -cp .:dremio-jdbc-driver-4.2.1-202004111451200819-0c3ecaea.jar Main | |
import java.sql.*; | |
import java.util.Properties; | |
public class Main { | |
public static void main(String[] args) { | |
final String DB_URL = "jdbc:dremio:direct=localhost:31010;"; | |
final String USER = "dremio"; | |
final String PASS = "dremio123"; | |
Properties props = new Properties(); | |
props.setProperty("user",USER); | |
props.setProperty("password",PASS); | |
Connection conn = null; | |
Statement stmt = null; | |
try { | |
System.out.println("Connecting to database..."); | |
conn = DriverManager.getConnection(DB_URL, props); | |
System.out.println("Creating statement..."); | |
stmt = conn.createStatement(); | |
String sql; | |
sql = "SELECT user"; | |
ResultSet rs = stmt.executeQuery(sql); | |
while (rs.next()) { | |
System.out.print(rs.getString("user")); | |
} | |
rs.close(); | |
stmt.close(); | |
conn.close(); | |
} catch (SQLException se) { | |
se.printStackTrace(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JDBC Driver: http://download.dremio.com/jdbc-driver/