Created sahrul-media
ChatBox
Headlines News :
Home » » Aplikasi Parkiran Menggunakan Java Database Xampp

Aplikasi Parkiran Menggunakan Java Database Xampp

Written By Gunawan on Rabu, 04 Juni 2014 | 21.21



LAPORAN UAS
PEMROGRAMAN JAVA
TENTANG
(APLIKASI PARKIR INTEGRASI DATABASE XAMPP)

Diajukan untuk memenuhi tugas (UAS) matakuliah Pemprograman Java






Disusun Oleh :
Nama               : Sahrul Gunawan
Npm                : 130403010045
Fak/Prodi        : FTI/TI






FAKULTAS TEKNOLOGI INFORMASI
PROGRAM STUDI TEKNIK INFORMATIKA
UNIVERSITAS KANJURUHAN MALANG
2014




KATA PENGANTAR


Puji syukur penulis panjatkan kehadirat Allah SWT, yang mana telah memberikan saya kekuatan serta kelancaran dalam menyelesaikan laporan matakuliah pemprograman java yang berjudul Aplikasi Parkir Database Mysql dapat selesai seperti waktu yang telah penulis rencanakan.
Tersusunnya laporan ini tentunya tidak lepas dari peran serta berbagai pihak yang telah memberikan bantuan secara materil dan spiritual, baik secara langsung maupun tidak langsung.
Oleh karena itu penulis mengucapkan terima kasih kepada :
1.      Bapak Amak Yunus pengasuh mata kuliah pemprograman java.
2.      Orang tua yang telah memberikan bantuan kepada penulis sehingga makalah ini dapat terselesaikan
3.      Teman-teman yang telah membantu dan memberikan dorongan semangat agar makalah ini dapat penulis selesaikan.

Semoga Tuhan Yang Maha Pengasih dan Penyayang membalas budi baik yang tulus dan ikhlas kepada semua pihak yang penulis sebutkan di atas.
Tak ada gading yang tak retak, untuk itu penulispun menyadari bahwa laporan yang telah penulis susun masih memiliki banyak kelemahan serta kekurangan-kekurangan baik dari segi teknis maupun  non-teknis. Untuk itu penulis membuka pintu yang selebar-lebarnya kepada semua pihak agar dapat memberikan saran dan kritik yang membangun demi penyempurnaan penulisan-penulisan mendatang. Dan apabila di dalam laporan ini terdapat hal-hal yang dianggap tidak berkenan di hati pembaca mohon dimaafkan.

Malang, 28 Mei 2014


Penulis

  



A.      Latar Belakang Program
Apa itu teknologi java? Java Sebagai sebuah bahasa pemrograman, Java dapat membuat seluruh bentuk aplikasi, desktop, web dan lainnya, sebagaimana dibuat dengan menggunakan bahasa pemrograman konvensional yang lain.  
Java adalah bahasa pemrograman yang berorientasi objek (OOP) dan dapat dijalankan pada berbagai platform sistem operasi. Perkembangan Java tidak hanya terfokus pada satu sistem operasi, tetapi dikembangkan untuk berbagai sistem operasi dan bersifat open source.
B.       Manfaat
1.    Sederhana (Simple)
2.    Terdistribusi (Distributed) Java dibuat untuk membuat aplikasi terdistribusi secara mudah dengan adanya libraries networking yang terintegrasi pada Java.
3.    Java dijalankan menggunakan interpreter yaitu Java Virtual Machine (JVM). Hal ini menyebabkan source code Java yang telah dikompilasi menjadi Java bytecodes dapat dijalankan pada platform yang berbeda-beda.

C.      Tujuan
1.    Menyelesaikan Ujian Akhir Semester matakuliah pemprograman Java semester 2.
2.    Mahasiswa mampu membuat program yang terhubung dengan Mysql Database dan bisa mengimplementasikan fungsi dari project tersebut dengan menggunakan bahasa pemrograman Java Neatbeans.



Ø  Tentang program yang dibuat
Project parkiran  yang dibuat ini dijalankan dengan software Neatbeans dengan menggunakan bahasa pemprograman Java. Fungsi-fungsi yang ditanamkan/digunakan dalam program yang dibuat meliputi Class, Jframe, databse, Jdbc:mysql, Xampp. Program tentang parkiran ini menggunakan database xampp, yang mana didalamnya harus mengkoneksikan terlebih dahulu antara neatbeans dengan xampp nya.
Ø  Cara kerja program
Cara kerja program parkir ini cukup sederhana, yaitu user harus mengaktifkan xampp dan nanti harus mengkoneksikan java neatbeans-nya ke xampp kemudian masukan Jdbc:mysql yang sudah ada dalam program neatbeans. Setelah di run maka akan tampil Jframe yang telah dibuat kalau bisa dijalankan berarti databasenya tidak error, dan kalau tidak bisa dijalankan maka kembali lagi user harus mengecek  seperti diawal sampai programnya bisa di jalankan.
Ø  Langkah – langkah menjalankan program
1.    User diminta untuk menjalankan Xampp, kemudian run Apache dan Mysql.
2.    User diminta untuk buka browser Mozila terus ketikan localhost/phpmyadmin.
3.    User diminta pilih database yang sudah dibuat seperti diprogramnya.
4.    Buka neatbeans klik project yang sudah dibuat, terus klik kanan libralies pilih add library kemudian pilih Mysql Jdbc-Driver.
5.    Tekan menu service klik kanan database pilih New Connection pilih Mysql Connector terus Next disitu nama database sama seperti databse yang di Xampp kemudian Next, Finish.
6.    Kemudian run programnya.



Ø  ScreenShoot Program :
1.         Tampilan awal program

2.         Diminta untuk memasukan no polisi dan terus pilih jenis Mobil/Motor kemudian tekan simpan.

3.         Pada tahap ini apabila kita mau keluar maka yang dicari noponya saja, kemudian akan tampil semua data yang dicari terus klik pada datanya, seperti gambar dibawah ini.


4.         Kemudian tekan tombol keluar maka akan otomatis akan tampil berapa biaya parkirannya, lebih jelasnya sepeti gambar dibawah ini.


Ø  Source Code Program :
1.    Class Jframe pertama dalm package form
package form;

/**
 *
 * @author Sahrul gunawan
 */
import konfigurasi.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
import java.text.*;

public class Utama extends javax.swing.JFrame {
    Connection cnn;
    Statement stm;
    ResultSet rs;
    DefaultTableModel isi;
    Object[] title= {"No Tiket","No Pol","Jenis","Tgl Masuk","Jam Masuk","Tgl Keluar","Jam Keluar"};
   
    public void buka_database(){
        try{
            Koneksi konek = new Koneksi("parkir_db");
            cnn=konek.aktifkan_koneksi();
           
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "Coba Lagi, Koneksi Gagal");
        }
    }
    final void tampil_parkir(){
        isi=new DefaultTableModel(null,title);
        try{
            stm=cnn.createStatement();
            String perintah="SELECT * from parkir order by no_tiket desc";
            rs=stm.executeQuery(perintah);
            while(rs.next()){
                String vnotik =rs.getString("no_tiket");
                String vnopol =rs.getString("nopol");
                String vjenis =rs.getString("jenis");
                String vtgl_msk =rs.getString("tgl_masuk");
                String vjam_msk =rs.getString("jam_masuk");
                String vtgl_klr =rs.getString("tgl_keluar");
                String vjam_klr =rs.getString("jam_keluar");

                String[] data ={vnotik,vnopol,vjenis,vtgl_msk,vjam_msk,vtgl_klr,vjam_klr};
                isi.addRow(data);
            }

        }catch(Exception e){
            System.out.println("gagal Mengambil barang :  "+e);
            System.exit(0);
        }
        tabel_parkir.setModel(isi);
    }
   
    final void dapatkan_data(){
        isi=new DefaultTableModel(null,title);
        try{
            stm=cnn.createStatement();
            String perintah="SELECT  tgl_keluar, jam_keluar, TIME_FORMAT('jam_keluar','%H')-TIME_FORMAT('jam_masuk','%H') AS durasi FROM parkir where nopol='"+cari.getText()+"';";
            rs=stm.executeQuery(perintah);
            while(rs.next()){
                kkeluar_tgl.setText(rs.getString("tgl_keluar"));
                kkeluar_jam.setText(rs.getString("jam_keluar"));
                durasi.setText(rs.getString("durasi"));
            }

        }catch(Exception e){
            System.out.println("gagal Mengambil dapat data :  "+e);
            System.exit(0);
        }
        tabel_parkir.setModel(isi);
    }
   
    public void cari_data(){
        isi=new DefaultTableModel(null,title);
        try{
           stm=cnn.createStatement();
           String perintah="select * from parkir where nopol like '%"+cari.getText()+"%'";
           rs=stm.executeQuery(perintah);
           while(rs.next()){
                String vnotik =rs.getString("no_tiket");
                String vnopol =rs.getString("nopol");
                String vjenis =rs.getString("jenis");
                String vtgl_msk =rs.getString("tgl_masuk");
                String vjam_msk =rs.getString("jam_masuk");
                String vtgl_klr =rs.getString("tgl_keluar");
                String vjam_klr =rs.getString("jam_keluar");

                String[] data ={vnotik,vnopol,vjenis,vtgl_msk,vjam_msk,vtgl_klr,vjam_klr};
                isi.addRow(data);
           }
        }catch(Exception e){
           System.out.println("gagal Mengambil barang :  "+e);
           System.exit(0);
       }
       tabel_parkir.setModel(isi);
    }
    public void akumulasi_biaya(){
        int vdurasi;
        double vbj, vbiaya;
       
        vdurasi=Integer.parseInt(durasi.getText());
        vbj=Double.parseDouble(kbj.getText());
       
        if(vdurasi<=1){
            vbiaya=vbj;
        }else{
            vbiaya=(vbj)+((vdurasi-1)*500);
        }
        biaya.setText(""+vbiaya);
    }
   
    public void bersih(){
        cari.setText("");
        kjenis.setText("");
        kbj.setText("");
        kkeluar_jam.setText("");
        kkeluar_tgl.setText("");
        kmasuk_jam.setText("");
        kmasuk_tgl.setText("");
        biaya.setText("");
        durasi.setText("");
       
    }
    public Utama() {
        initComponents();
        tengah tengah = new tengah(this);
        buka_database();
        tampil_parkir();
    }

    /** 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() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        nopol = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jenis = new javax.swing.JComboBox();
        Simpan = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        cari = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        kjenis = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        kmasuk_tgl = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        kmasuk_jam = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        kkeluar_jam = new javax.swing.JTextField();
        kkeluar_tgl = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        kbj = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        durasi = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        biaya = new javax.swing.JTextField();
        keluar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabel_parkir = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 0, 255));

        jTabbedPane1.setBackground(new java.awt.Color(255, 255, 225));

        jPanel1.setBackground(new java.awt.Color(255, 255, 225));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setText("No Polisi");

        nopol.setForeground(new java.awt.Color(0, 0, 255));

        jLabel3.setText("Jenis");

        jenis.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PILIH", "Motor", "Mobil" }));
        jenis.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        Simpan.setBackground(new java.awt.Color(153, 180, 209));
        Simpan.setText("Simpan");
        Simpan.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        Simpan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SimpanActionPerformed(evt);
            }
        });

        jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/sm.png"))); // NOI18N
        jLabel13.setText("jLabel13");
        jLabel13.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel13.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jenis, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(nopol, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)))
                    .addComponent(Simpan, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(nopol, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jenis, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Simpan, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel13)
                .addGap(0, 84, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Parkir Masuk", jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 225));
        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        cari.setForeground(new java.awt.Color(0, 0, 255));
        cari.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                cariKeyReleased(evt);
            }
        });

        jLabel4.setText("Cari Nopol");

        kjenis.setEditable(false);
        kjenis.setForeground(new java.awt.Color(0, 0, 255));
        kjenis.addInputMethodListener(new java.awt.event.InputMethodListener() {
            public void caretPositionChanged(java.awt.event.InputMethodEvent evt) {
            }
            public void inputMethodTextChanged(java.awt.event.InputMethodEvent evt) {
                kjenisInputMethodTextChanged(evt);
            }
        });
        kjenis.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kjenisKeyReleased(evt);
            }
        });

        jLabel5.setText("Jenis");

        kmasuk_tgl.setEditable(false);
        kmasuk_tgl.setForeground(new java.awt.Color(0, 0, 255));
        kmasuk_tgl.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kmasuk_tglKeyReleased(evt);
            }
        });

        jLabel6.setText("Masuk tgl :");

        kmasuk_jam.setForeground(new java.awt.Color(0, 0, 255));
        kmasuk_jam.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kmasuk_jamKeyReleased(evt);
            }
        });

        jLabel7.setText("Jam :");

        kkeluar_jam.setForeground(new java.awt.Color(0, 0, 255));
        kkeluar_jam.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kkeluar_jamKeyReleased(evt);
            }
        });

        kkeluar_tgl.setForeground(new java.awt.Color(0, 0, 255));
        kkeluar_tgl.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kkeluar_tglKeyReleased(evt);
            }
        });

        jLabel8.setText("Keluar tgl :");

        jLabel9.setText("Jam :");

        kbj.setEditable(false);
        kbj.setForeground(new java.awt.Color(0, 0, 255));
        kbj.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                kbjKeyReleased(evt);
            }
        });

        jLabel10.setText("B/J  :");

        jLabel11.setText("Durasi : ");

        durasi.setForeground(new java.awt.Color(0, 0, 255));
        durasi.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                durasiKeyReleased(evt);
            }
        });

        jLabel12.setText("Biaya:");

        biaya.setBackground(new java.awt.Color(255, 255, 153));
        biaya.setForeground(new java.awt.Color(0, 0, 255));
        biaya.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                biayaKeyReleased(evt);
            }
        });

        keluar.setBackground(java.awt.SystemColor.activeCaption);
        keluar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ass.png"))); // NOI18N
        keluar.setText("Keluar");
        keluar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        keluar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                keluarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5)
                            .addComponent(jLabel4))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(kjenis)
                                    .addComponent(kmasuk_tgl, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(kbj)
                                    .addComponent(kmasuk_jam, javax.swing.GroupLayout.Alignment.LEADING)))
                            .addComponent(cari, javax.swing.GroupLayout.PREFERRED_SIZE, 222, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel8)
                            .addComponent(jLabel11))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(durasi, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(kkeluar_tgl, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(biaya)
                            .addComponent(kkeluar_jam))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(keluar, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1340, 1340, 1340))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(keluar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(cari, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(kjenis, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(kbj, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(kmasuk_tgl, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(kmasuk_jam, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(kkeluar_tgl, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(kkeluar_jam, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(durasi, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(biaya, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))))
                .addContainerGap(63, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Parkir keluar", jPanel2);

        tabel_parkir.setBackground(new java.awt.Color(153, 180, 209));
        tabel_parkir.setForeground(new java.awt.Color(0, 0, 255));
        tabel_parkir.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tabel_parkir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        tabel_parkir.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tabel_parkirMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tabel_parkir);

        jLabel1.setFont(new java.awt.Font("Berlin Sans FB Demi", 1, 18)); // NOI18N
        jLabel1.setText("SISTEM PARKIR UNIV.KANJURUHAN MALANG");
        jLabel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(jLabel1)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(26, 26, 26)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 346, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                       

private void SimpanActionPerformed(java.awt.event.ActionEvent evt) {                                      
    if( !"".equals(nopol.getText())){
    try{
        stm=cnn.createStatement();
        String perintah="INSERT INTO parkir(nopol,jenis,tgl_masuk,jam_masuk) VALUES (upper('"+nopol.getText()+"'),'"+jenis.getSelectedItem()+"',CURDATE(),CURTIME());";
        stm.executeUpdate(perintah);
        JOptionPane.showMessageDialog(null,"Data Berhasil Disimpan");
        nopol.setText("");
    }catch(Exception e){
        JOptionPane.showMessageDialog(null,"Data Gagal Disimpan");
        System.out.println("erornya : "+e);
    }
    tampil_parkir();
    }else{
        JOptionPane.showMessageDialog(null, "Anda Belum Input Nopol");
    }
}                                     

private void cariKeyReleased(java.awt.event.KeyEvent evt) {                                
    cari_data();
}   


private void tabel_parkirMouseClicked(java.awt.event.MouseEvent evt) {                                         
    bersih();
    cari.setText(tabel_parkir.getValueAt(tabel_parkir.getSelectedRow(),1).toString());
    kjenis.setText(tabel_parkir.getValueAt(tabel_parkir.getSelectedRow(),2).toString());
    kmasuk_tgl.setText(tabel_parkir.getValueAt(tabel_parkir.getSelectedRow(),3).toString());
    kmasuk_jam.setText(tabel_parkir.getValueAt(tabel_parkir.getSelectedRow(),4).toString());
   
    try{
        stm=cnn.createStatement();
        String perintah="SELECT tarif from kendaraan where jenis='"+kjenis.getText()+"'";
        rs=stm.executeQuery(perintah);
        while(rs.next()){
           kbj.setText(rs.getString("tarif"));
        }
           
        }catch(Exception e){
            JOptionPane.showMessageDialog(null ,"Gagal  ");
            System.out.println("Erornya :  "+e);
            System.exit(0);
        }
}                                        

private void kjenisInputMethodTextChanged(java.awt.event.InputMethodEvent evt) {                                             
   
}                                            

private void keluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
    if( !"".equals(cari.getText())){
    try{
        stm=cnn.createStatement();
        String perintah="update parkir set tgl_keluar=curdate(), jam_keluar=curtime() where nopol='"+cari.getText()+"'";
        stm.executeUpdate(perintah);
        JOptionPane.showMessageDialog(null,"Berhasil Update Keluar");
        nopol.setText("");
    }catch(Exception e){
        JOptionPane.showMessageDialog(null,"Data Gagal Diupdate");
        System.out.println("erornya : "+e);
    }
    dapatkan_data();
    akumulasi_biaya();
    tampil_parkir();
    }else{
        JOptionPane.showMessageDialog(null, "Anda Belum Input Nopol");
    }
}                                     

    /**
     * @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(Utama.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Utama.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Utama.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Utama.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 Utama().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton Simpan;
    private javax.swing.JTextField biaya;
    private javax.swing.JTextField cari;
    private javax.swing.JTextField durasi;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JComboBox jenis;
    private javax.swing.JTextField kbj;
    private javax.swing.JButton keluar;
    private javax.swing.JTextField kjenis;
    private javax.swing.JTextField kkeluar_jam;
    private javax.swing.JTextField kkeluar_tgl;
    private javax.swing.JTextField kmasuk_jam;
    private javax.swing.JTextField kmasuk_tgl;
    private javax.swing.JTextField nopol;
    private javax.swing.JTable tabel_parkir;
    // End of variables declaration                  
}                           



2.         Source Code Class koneksi
package konfigurasi;

/**
 *
 * @author sahrul gunawan*/
import java.sql.*;
import javax.swing.JOptionPane;

public class Koneksi{
    String url, username, password;
   
    //Constructor
    public Koneksi(String database){
        this.url="jdbc:mysql://localhost:3306/"+database;
        this.username="root";
        this.password="";
    }
   
    public Connection aktifkan_koneksi(){
        Connection konek=null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            konek=DriverManager.getConnection(this.url,this.username,this.password);
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,"Priksa Nama Database, Koneksi Gagal");
            System.out.println("Erornya :"+e);
            System.exit(0);
        }
        return konek;
    }

}

3.         Source Code Konfigurasi
package konfigurasi;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;

/**
 *
 * @author sahrul gunawan
 */
public class tengah {
     public tengah(JFrame form) {
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (dim.width - form.getSize().width)/2;
        int y = (dim.height - form.getSize().height)/2;
        form.setLocation(x,y);
    }
}



Share this article :

5 komentar:

  1. thanxxx nih Gan dah mo berbagi...
    bagus buat belajar......

    BalasHapus
  2. gan kalo Struktur databasenya gimana?

    BalasHapus
  3. Mohon ijin untuk bahan belajar gan

    BalasHapus
  4. Mntap gan, bisa bikin di studio android g gan, minta saran suhu, ane pengen tau aplikasi lewat hp android operasi nya, data base tersimpan otomatis di sql..

    BalasHapus
  5. CARA MENAMBAHKAN SISTEM LOGIN

    BalasHapus

English French German Spain Italian Japanese Korean Chinese Simplified

Tweets

FunsPage

 
Support : Creating Website | media-template | sahrul Template
Proudly powered by Blogger
Copyright © 2011. MEDIA BELAJAR - All Rights Reserved
Template Design by Creating Website Published by sahrul-media