/** * Creates JUnit test router. Note that router must have a no-arg constructor. * * @return JUnit router instance. */ @SuppressWarnings({"unchecked"}) private GridTestRouter createRouter() { try { if (routerCls == null) { routerCls = (Class<? extends GridTestRouter>) Class.forName(routerClsName); } else { routerClsName = routerCls.getName(); } return routerCls.newInstance(); } catch (ClassNotFoundException e) { throw new GridRuntimeException("Failed to initialize JUnit router: " + routerClsName, e); } catch (IllegalAccessException e) { throw new GridRuntimeException("Failed to initialize JUnit router: " + routerClsName, e); } catch (InstantiationException e) { throw new GridRuntimeException("Failed to initialize JUnit router: " + routerClsName, e); } }
/** * Runs JDBC example. * * @param args Command line arguments. * @throws Exception In case of error. */ public static void main(String[] args) throws Exception { Grid grid = G.start("examples/config/spring-cache.xml"); Connection conn = null; try { // Populate cache with data. populate(grid.cache(CACHE_NAME)); // Register JDBC driver. Class.forName("org.gridgain.jdbc.GridJdbcDriver"); // Open JDBC connection. conn = DriverManager.getConnection("jdbc:gridgain://localhost/" + CACHE_NAME, configuration()); X.println(">>>"); // Query all persons. queryAllPersons(conn); X.println(">>>"); // Query person older than 30 years. queryPersons(conn, 30); X.println(">>>"); // Query persons working in GridGain. queryPersonsInOrganization(conn, "GridGain"); X.println(">>>"); } finally { // Close JDBC connection. if (conn != null) conn.close(); G.stop(true); } }