OmniSciDB  04ee39c94c
SampleJDBC Class Reference
+ Collaboration diagram for SampleJDBC:

Static Public Member Functions

static void main (String[] args)
 

Static Package Attributes

static final String JDBC_DRIVER = "com.omnisci.jdbc.OmniSciDriver"
 
static final String DB_URL = "jdbc:omnisci:localhost:6274:mapd"
 
static final String PROTOCOL = "binary"
 
static final String USER = "mapd"
 
static final String PASS = "HyperInteractive"
 

Detailed Description

Definition at line 24 of file SampleJDBC.java.

Member Function Documentation

◆ main()

static void SampleJDBC.main ( String []  args)
inlinestatic

Definition at line 36 of file SampleJDBC.java.

References sql(), and Experimental.String.

36  {
37  Connection conn = null;
38  Statement stmt = null;
39  try {
40  // STEP 1: Register JDBC driver
41  Class.forName(JDBC_DRIVER);
42 
43  // STEP 2: Open a connection
44  Properties pt = new Properties();
45  pt.setProperty("user", USER);
46  pt.setProperty("password", PASS);
47  pt.setProperty("protocol", PROTOCOL);
48  conn = DriverManager.getConnection(DB_URL, pt);
49 
50  // STEP 3: Execute a query
51  stmt = conn.createStatement();
52 
53  String sql = "SELECT uniquecarrier from flights_2008_10k"
54  + " GROUP BY uniquecarrier limit 5";
55  ResultSet rs = stmt.executeQuery(sql);
56 
57  // STEP 4: Extract data from result set
58  while (rs.next()) {
59  String uniquecarrier = rs.getString("uniquecarrier");
60  System.out.println("uniquecarrier: " + uniquecarrier);
61  }
62 
63  // STEP 5: Clean-up environment
64  rs.close();
65  stmt.close();
66  conn.close();
67  } catch (SQLException se) {
68  // Handle errors for JDBC
69  se.printStackTrace();
70  } catch (Exception e) {
71  // Handle errors for Class.forName
72  e.printStackTrace();
73  } finally {
74  // finally block used to close resources
75  try {
76  if (stmt != null) {
77  stmt.close();
78  }
79  } catch (SQLException se2) {
80  } // nothing we can do
81  try {
82  if (conn != null) {
83  conn.close();
84  }
85  } catch (SQLException se) {
86  se.printStackTrace();
87  } // end finally try
88  } // end try
89  } // end main
static final String PASS
Definition: SampleJDBC.java:34
static final String PROTOCOL
Definition: SampleJDBC.java:30
auto sql(const std::string &sql_stmts)
static final String USER
Definition: SampleJDBC.java:33
static final String DB_URL
Definition: SampleJDBC.java:27
static final String JDBC_DRIVER
Definition: SampleJDBC.java:26
+ Here is the call graph for this function:

Member Data Documentation

◆ DB_URL

final String SampleJDBC.DB_URL = "jdbc:omnisci:localhost:6274:mapd"
staticpackage

Definition at line 27 of file SampleJDBC.java.

◆ JDBC_DRIVER

final String SampleJDBC.JDBC_DRIVER = "com.omnisci.jdbc.OmniSciDriver"
staticpackage

Definition at line 26 of file SampleJDBC.java.

◆ PASS

final String SampleJDBC.PASS = "HyperInteractive"
staticpackage

Definition at line 34 of file SampleJDBC.java.

◆ PROTOCOL

final String SampleJDBC.PROTOCOL = "binary"
staticpackage

Definition at line 30 of file SampleJDBC.java.

◆ USER

final String SampleJDBC.USER = "mapd"
staticpackage

Definition at line 33 of file SampleJDBC.java.


The documentation for this class was generated from the following file: