User Tools

Site Tools


classes:general:dbsamples:java_mysql

This is an old revision of the document!


import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger;

public class JdbcMySQLVersion {

  public static void main(String[] args) {
      String url = "jdbc:mysql://rei.cs.ndsu.nodak.edu:3306/olympiad?useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
      String user = "olympiad";
      String password = "B6pLyr49";
      String query = "SELECT event_date FROM so15_tournament WHERE active=FALSE";
      try (Connection con = DriverManager.getConnection(url, user, password);
          Statement st = con.createStatement();
          ResultSet rs = st.executeQuery(query)) {
          while (rs.next()) {
              System.out.println(rs.getString(1));
          }
      } catch (SQLException ex) {
          Logger lgr = Logger.getLogger(JdbcMySQLVersion.class.getName());
          lgr.log(Level.SEVERE, ex.getMessage(), ex);
      }
  }

}

classes/general/dbsamples/java_mysql.1603732932.txt.gz · Last modified: 2020/10/26 12:22 by localadmin