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

Static Public Member Functions

static void main (String[] args)
 

Static Package Attributes

static final String JDBC_DRIVER = "com.mapd.jdbc.MapDDriver"
 
static final String DB_URL = "jdbc:mapd:myHost.com:6274:mapd"
 
static final String USER = "myUserName"
 
static final String PASS = "myPassword"
 

Detailed Description

Definition at line 3 of file Batch.java.

Member Function Documentation

◆ main()

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

Definition at line 12 of file Batch.java.

12  {
13  Connection conn = null;
14  Statement stmt = null;
15  PreparedStatement pstmt = null;
16 
17  try {
18  // STEP 1: Register the JDBC driver
19  Class.forName(JDBC_DRIVER);
20 
21  // STEP 2: Open a connection
22  conn = DriverManager.getConnection(DB_URL, USER, PASS);
23  stmt = conn.createStatement();
24  stmt.executeUpdate(
25  "create table girl_groups(name1 varchar(20), group_rank integer, name2 varchar(20))");
26  stmt.close();
27  conn.setAutoCommit(false);
28 
29  pstmt = conn.prepareStatement("insert into girl_groups values(?,?,?)");
30  pstmt.setString(1, "Orange Caramel");
31  pstmt.setInt(2, 5);
32  pstmt.setString(3, "2NE1");
33  pstmt.addBatch();
34  pstmt.setString(1, "4Minute");
35  pstmt.setInt(2, 6);
36  pstmt.setString(3, "EXID");
37  pstmt.addBatch();
38  pstmt.executeBatch();
39  conn.commit();
40  pstmt.close();
41  conn.close();
42  } catch (SQLException se) {
43  // Handle errors for JDBC
44  se.printStackTrace();
45  } catch (Exception e) {
46  // Handle errors for Class.forName
47  e.printStackTrace();
48  } finally {
49  // finally block used to close resources
50  try {
51  if (pstmt != null) {
52  stmt.close();
53  pstmt.close();
54  }
55  } catch (SQLException se2) {
56  } // nothing we can do
57  try {
58  if (conn != null) {
59  conn.close();
60  }
61  } catch (SQLException se) {
62  se.printStackTrace();
63  } // end finally try
64  } // end try
65  } // end main
static final String DB_URL
Definition: Batch.java:6
static final String PASS
Definition: Batch.java:10
static final String USER
Definition: Batch.java:9
static final String JDBC_DRIVER
Definition: Batch.java:5

Member Data Documentation

◆ DB_URL

final String Batch.DB_URL = "jdbc:mapd:myHost.com:6274:mapd"
staticpackage

Definition at line 6 of file Batch.java.

◆ JDBC_DRIVER

final String Batch.JDBC_DRIVER = "com.mapd.jdbc.MapDDriver"
staticpackage

Definition at line 5 of file Batch.java.

◆ PASS

final String Batch.PASS = "myPassword"
staticpackage

Definition at line 10 of file Batch.java.

◆ USER

final String Batch.USER = "myUserName"
staticpackage

Definition at line 9 of file Batch.java.


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