Aplikasi Penjualan Sederhana, Menggunakan Java Swing dan Java Persistence API


Baru saja saya selesai membuat aplikasi penjualan sederhana menggunakan Java Swing dan Java Persistence API, aplikasinya sederhana, hanya menambahkan Barang, Kategori, Penjualan. dan belum sampai pembuatan laporan :D. Mungkin bisa teman-teman tambahkan sendiri 😀

Teknik pembuatan aplikasi ini adalah terinspirasi framework RubyOnRails, nanti di sourcecodenya teman-teman bisa melihat adanya Controller dan Helper, mirip di RubyOnRails, cuma bedanya ini gak pake ActiveRecord 😀 Soalnya menggunakan Java Persistence API, jadi ya gak perlu lagi bikin ActiveRecord 😀

Dibawah ini adalah screenshoot tampilannya :

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Aplikasi Penjualan 1.0

Aplikasi Penjualan Sederhana

Silahkan download sourcecodenya disini :

Referensi :

Iklan

43 pemikiran pada “Aplikasi Penjualan Sederhana, Menggunakan Java Swing dan Java Persistence API

  1. mas, nanya kmren saya buat class entity dari database yaitu tabel penduduk sama tabel kartu_keluarga.
    keduanya saling berelasi tetapi pas saya mw jalankan projectnya muncul exception sbb (padahal saya belum meng-instance ke dua entity class tsb):

    Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on org.mktp.entity.KartuKeluarga.nikKk references an unknown entity: org.mktp.entity.Penduduk
    at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:81)
    at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:499)
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:304)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
    … 72 more

    berikut petikan kode entity class-nya :
    #Penduduk
    @OneToMany(cascade = CascadeType.ALL, mappedBy = “nikKk”)
    private List kartuKeluargaList;

    #KartuKeluarga
    @JoinColumn(name = “nik_kk”, referencedColumnName = “nik”)
    @ManyToOne(optional = false)
    private Penduduk nikKk;

    Sedangkan ini adalah strukur tabel nya :

  2. run:
    [EL Info]: 2010-03-29 11:36:46.093–ServerSession(229902)–EclipseLink, version: Eclipse Persistence Services – 2.0.0.v20091127-r5931
    [EL Severe]: 2010-03-29 11:36:48.312–ServerSession(229902)–Local Exception Stack:
    Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    Last packet sent to the server was 0 ms ago.
    Error Code: 0
    Exception in thread “main” javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    Last packet sent to the server was 0 ms ago.
    Error Code: 0
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:392)
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:368)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
    at khannedy.enterprise.penjualan.util.PersistenceContext.createEntityManager(PersistenceContext.java:28)
    at khannedy.enterprise.penjualan.Main.main(Main.java:22)
    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    Last packet sent to the server was 0 ms ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    … 9 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.(Socket.java:366)
    at java.net.Socket.(Socket.java:209)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
    at com.mysql.jdbc.MysqlIO.(MysqlIO.java:280)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
    … 21 more

    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:151)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:207)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:195)
    at khannedy.enterprise.penjualan.util.PersistenceContext.createEntityManager(PersistenceContext.java:28)
    at khannedy.enterprise.penjualan.Main.main(Main.java:22)
    Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services – 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    Last packet sent to the server was 0 ms ago.
    Error Code: 0
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:368)
    … 5 more
    Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    Last packet sent to the server was 0 ms ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:154)
    at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:98)
    … 9 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at java.net.Socket.(Socket.java:366)
    at java.net.Socket.(Socket.java:209)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
    at com.mysql.jdbc.MysqlIO.(MysqlIO.java:280)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
    … 21 more
    Java Result: 1
    BUILD SUCCESSFUL (total time: 5 seconds)

    pada saat saya ingin menjalankan aplikasi itu..muncul pesan seperti itu…
    kira – kira kesalahan atau yang belum saya lakukan ada di mana ya mas?
    mohon bantuannya…..untuk referensi skripsi saya….
    terima kasih sebelumnya…..

  3. mas,orphanRemol dan crudPanel saya kuk error y ??
    padahal lib javax.persistence sudah saya masukan. . .
    mohon bimbingannya y mas . .
    tiingkyu ^o^

  4. mas…minta tlong dong gmn nich programnyz g bs jln…gw msh bru bljr jpa neh..
    cb gw jlnin prgrmx tpi ktanya “Class “penjualan barang” does not have a main methode
    mhon bimbinganx mas….ma ksh..

  5. C:\Users\user\Desktop\penjualan\src\khannedy\enterprise\penjualan\Main.java:7: package javax.persistence does not exist
    import javax.persistence.EntityManager;
    ^

    butuh library persistence tambahan kah ? thanks

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s