Advertisement
Guest User

Untitled

a guest
May 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. public class DAO {
  3.  
  4. String SELECT_QUERY = "INSERT INTO info (name) values (?)";
  5.  
  6. public void h2GetConnection() {
  7.  
  8. MySAXApp mySAXApp = new MySAXApp();
  9.  
  10. try {
  11.  
  12. Class.forName("com.mysql.cj.jdbc.Driver");
  13. String url = "jdbc:mysql://localhost:3306/news" +
  14. "?verifyServerCertificate=false" +
  15. "&useSSL=false" +
  16. "&requireSSL=false" +
  17. "&useLegacyDatetimeCode=false" +
  18. "&amp" +
  19. "&serverTimezone=UTC";
  20. try {
  21. Connection connection = DriverManager.getConnection(url, "root", "root");
  22. System.out.println("work");
  23.  
  24. Statement statement = null;
  25. statement = connection.createStatement();
  26.  
  27.  
  28. for (int i = 3; i < mySAXApp.a.length; i++) {
  29.  
  30. PreparedStatement preparedStatement = connection.prepareStatement(SELECT_QUERY);
  31. preparedStatement.setString(1, mySAXApp.a[i]);
  32. preparedStatement.addBatch();
  33. preparedStatement.executeBatch();
  34. }
  35.  
  36.  
  37. } catch (SQLException e) {
  38. System.out.println(e);
  39. }
  40.  
  41. } catch (Exception e) {
  42.  
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement