DataAllService.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.data.datarepo.services;
  2. import com.data.datarepo.utils.DataSource;
  3. import com.mysql.cj.jdbc.MysqlDataSource;
  4. import java.sql.Connection;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. public class DataAllService {
  11. DataService dataService=new DataService();
  12. public void selectAll() throws SQLException {
  13. Connection connection = null;
  14. String selectSQL = "select repo_name from data_sync_table";
  15. PreparedStatement prepStmt = null;
  16. try {
  17. MysqlDataSource basicDS = DataSource.getInstance().getMySqlDS();
  18. connection = basicDS.getConnection();
  19. prepStmt = connection.prepareStatement(selectSQL);
  20. ResultSet rs = prepStmt.executeQuery();
  21. while(rs.next()){
  22. // dataService.testSelect(rs.getString("repo_name"),rs.getString("table_name"),rs.getString("table_name"));
  23. }
  24. }catch (Exception e){
  25. e.printStackTrace();
  26. }finally {
  27. if (prepStmt != null) {
  28. prepStmt.close();
  29. }
  30. if (connection != null) {
  31. connection.close();
  32. }
  33. }
  34. }
  35. }