Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. @Test
  2. @Rollback(true)
  3. public void checkMysqlConnection() {
  4. Connection connection = null;
  5. ResultSet tableDatasRsult = null;
  6. try {
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Properties properties = new Properties();
  9. properties.setProperty("user", "root");
  10. properties.setProperty("password", "root");
  11. String url = "127.0.0.1:3306/unicity";
  12. connection = DriverManager.getConnection("jdbc:mysql://" + url, properties);
  13. Assert.assertNotNull(connection);
  14. String sqlq = "select DIST_ID,PV_DATE,POST_DATE from odh";
  15. PreparedStatement preparedStatement = connection.prepareStatement(sqlq);
  16. tableDatasRsult = preparedStatement.executeQuery();
  17. ArrayList<OdhDO> odhDOs = new ArrayList<>();
  18. while (tableDatasRsult.next()) {
  19. OdhDO odhDO = new OdhDO();
  20. odhDO.setDistId(tableDatasRsult.getLong("DIST_ID"));
  21. odhDO.setPvDate(tableDatasRsult.getString("PV_DATE"));
  22. odhDO.setPostDate(tableDatasRsult.getString("POST_DATE"));
  23. odhDOs.add(odhDO);
  24.  
  25. Map<String, Object> params = new HashMap<>();
  26. params.put(odhDO.getDistId().toString(), odhDO);
  27. System.out.println(params);
  28.  
  29. }
  30.  
  31. } catch (ClassNotFoundException e) {
  32. System.out.println("MySql Driver Class Not Found Exception");
  33. e.printStackTrace();
  34. } catch (SQLException e) {
  35. System.out.println("Sql Exception");
  36. e.printStackTrace();
  37. } finally {
  38. try {
  39. connection.close();
  40. } catch (SQLException e) {
  41. e.printStackTrace();
  42. }
  43. }
  44.  
  45. }
  46.  
  47. @Test
  48. @Rollback(true)
  49.  
  50. public void checkneo4jConnection(){
  51.  
  52. String URL= "http://localhost:7474";
  53. Configuration configuration = new Configuration();
  54. configuration.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver").setURI(URL).setCredentials("neo4j", "admin");
  55.  
  56.  
  57. String cypher = "MATCH (Distributor) WHERE Distributor.DISTID IN {odhDOs} RETURN Distributor";
  58. Map<String, Object> params = new HashMap<>();
  59. List<String> odhDOs = new ArrayList<>();
  60. params.put("odhDOs", odhDOs);
  61.  
  62. //add some names to the names list
  63. //params.put(key, value)
  64.  
  65. }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement