Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Mathis
- */
- public class Fahrradverleih extends javax.swing.JFrame {
- /**
- * Creates new form Fahrradverleih
- */
- public Fahrradverleih() {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jScrollPane1 = new javax.swing.JScrollPane();
- taAusgabe2 = new javax.swing.JTextArea();
- bKundeFT = new javax.swing.JButton();
- jScrollPane2 = new javax.swing.JScrollPane();
- taAusgabe1 = new javax.swing.JTextArea();
- bKunden = new javax.swing.JButton();
- bTT = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- taAusgabe2.setColumns(20);
- taAusgabe2.setRows(5);
- jScrollPane1.setViewportView(taAusgabe2);
- bKundeFT.setText("Kunde -> Fahrrad + Termin");
- bKundeFT.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bKundeFTActionPerformed(evt);
- }
- });
- taAusgabe1.setColumns(20);
- taAusgabe1.setRows(5);
- jScrollPane2.setViewportView(taAusgabe1);
- bKunden.setText("Kunden");
- bKunden.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bKundenActionPerformed(evt);
- }
- });
- bTT.setText("Tourteilnehmer + Termin");
- bTT.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- bTTActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(26, 26, 26)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(bKundeFT, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)
- .addComponent(bTT, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .addComponent(bKunden, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(92, Short.MAX_VALUE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(bKunden)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
- .addComponent(jScrollPane1))
- .addGap(19, 19, 19))
- .addGroup(layout.createSequentialGroup()
- .addComponent(bKundeFT)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(bTT)
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
- );
- pack();
- }// </editor-fold>
- private void bKundeFTActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:derby:F:\\Q1\\Info\\Q3\\Db_Beziehungen\\Db_Beziehungen");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM Verleih");
- taAusgabe2.setText("");
- while (rs.next()) {
- taAusgabe2.append(rs.getString("Verleihnummer") + "\t" + rs.getString("Kundennummer") + "\t" + rs.getString("Fahrradnummer") + "\t" + rs.getString("Termin"));
- taAusgabe2.append("\n");
- }
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- } // TODO add your handling code here:
- }
- private void bKundenActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:derby:F:\\Q1\\Info\\Q3\\Db_Beziehungen\\Db_Beziehungen");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT * FROM Kunde");
- taAusgabe1.setText("");
- while (rs.next()) {
- taAusgabe1.append(rs.getString("Kundennummer") + "\t" + rs.getString("Name") + "\t" + rs.getString("Vorname"));
- taAusgabe1.append("\n");
- }
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- } // TODO add your handling code here:
- }
- private void bTTActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- Connection con = DriverManager.getConnection("jdbc:derby:F:\\Q1\\Info\\Q3\\Db_Beziehungen\\Db_Beziehungen");
- Statement stmt = con.createStatement();
- int i = 0;
- ResultSet rs = stmt.executeQuery("SELECT * FROM Belegung WHERE Tournummer = 'T1'");
- while (rs.next()) {
- i=i++;
- }
- stmt.executeUpdate("UPDATE Tour SET Teilnehmerzahl = '"+i+"' WHERE Tournummer = 'T1'");
- i=0;
- rs = stmt.executeQuery("SELECT * FROM Belegung WHERE Tournummer = 'T2'");
- while (rs.next()) {
- i=i++;
- }
- stmt.executeUpdate("UPDATE Tour SET Teilnehmerzahl = '"+i+"' WHERE Tournummer = 'T2'");
- rs = stmt.executeQuery("SELECT * FROM Tour");
- while (rs.next()) {
- taAusgabe2.append(rs.getString("Tournummer") + "\t" + rs.getString("Tourtermin") + "\t" + rs.getString("Länge") + "\t" + rs.getString("Teilnehmerzahl"));
- taAusgabe2.append("\n");
- }
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- } // TODO add your handling code here:
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- } catch (ClassNotFoundException ex) {
- java.util.logging.Logger.getLogger(Fahrradverleih.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Fahrradverleih.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Fahrradverleih.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Fahrradverleih.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Fahrradverleih().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton bKundeFT;
- private javax.swing.JButton bKunden;
- private javax.swing.JButton bTT;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JScrollPane jScrollPane2;
- private javax.swing.JTextArea taAusgabe1;
- private javax.swing.JTextArea taAusgabe2;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement