Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aquarium;
- import java.sql.*;
- /**
- *
- * @author RiskyShenanigan
- */
- public class Menu extends javax.swing.JFrame {
- SensorReadings sen = new SensorReadings();
- String url = "jdbc:mysql://localhost:3306/";
- String dbName = "myDatabase";
- String driver = "com.mysql.jdbc.Driver";
- String userName = "root";
- String password = "candy";
- Connection con;
- /** Creates new form Menu */
- public Menu() {
- initComponents();
- }
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- try{
- con = DriverManager.getConnection(url+dbName,userName,password);
- System.out.println("Connected to the database");
- Statement st = con.createStatement();
- ResultSet rt = st.executeQuery("SELECT * FROM user_settings;");
- while(rt.next()){
- sen.jTextField10.setText(Integer.toString(rt.getInt(1)));
- sen.jTextField11.setText(Integer.toString(rt.getInt(2)));
- sen.jTextField12.setText(Integer.toString(rt.getInt(3)));
- sen.jTextField13.setText(Integer.toString(rt.getInt(4)));
- sen.jTextField14.setText(Integer.toString(rt.getInt(5)));
- sen.jTextField17.setText(Integer.toString(rt.getInt(6)));
- sen.jTextField15.setText(Integer.toString(rt.getInt(7)));
- sen.jTextField16.setText(Double.toString(rt.getDouble(8)));
- con.close();
- System.out.println("Disconnected from database");
- }
- } catch (SQLException e) {System.err.println("ERROR: " + e.getMessage()); }
- new SensorReadings().setVisible(true);
- this.dispose();
- }
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
- new Login().setVisible(true);
- this.dispose();
- }
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- new DatabaseMenu().setVisible(true);
- this.dispose();
- }
- private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
- new Administrator().setVisible(true);
- this.dispose();
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Menu().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton5;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- // End of variables declaration
- }
Add Comment
Please, Sign In to add comment