Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DAO {
- String SELECT_QUERY = "INSERT INTO info (name) values (?)";
- public void h2GetConnection() {
- MySAXApp mySAXApp = new MySAXApp();
- try {
- Class.forName("com.mysql.cj.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/news" +
- "?verifyServerCertificate=false" +
- "&useSSL=false" +
- "&requireSSL=false" +
- "&useLegacyDatetimeCode=false" +
- "&" +
- "&serverTimezone=UTC";
- try {
- Connection connection = DriverManager.getConnection(url, "root", "root");
- System.out.println("work");
- Statement statement = null;
- statement = connection.createStatement();
- for (int i = 3; i < mySAXApp.a.length; i++) {
- PreparedStatement preparedStatement = connection.prepareStatement(SELECT_QUERY);
- preparedStatement.setString(1, mySAXApp.a[i]);
- preparedStatement.addBatch();
- preparedStatement.executeBatch();
- }
- } catch (SQLException e) {
- System.out.println(e);
- }
- } catch (Exception e) {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement