├── nbproject ├── private │ ├── config.properties │ ├── private.properties │ └── private.xml ├── genfiles.properties ├── project.xml └── project.properties ├── src ├── config.config └── dbtest │ ├── Config.java │ ├── AddNewStudent.form │ ├── DeleteStudentDetails.form │ ├── ModifyStudentDetails.form │ ├── Home.java │ ├── AddNewStudent.java │ ├── DeleteStudentDetails.java │ ├── Home.form │ └── ModifyStudentDetails.java ├── manifest.mf ├── Comfortaa ├── Comfortaa-Bold.ttf ├── Comfortaa-Light.ttf ├── Comfortaa-Regular.ttf └── OFL.txt ├── screenshots ├── dbmsproj-1.PNG ├── dbmsproj-2.PNG ├── dbmsproj-3.PNG └── dbmsproj-4.PNG ├── README.md └── Students_Table.sql /nbproject/private/config.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/config.config: -------------------------------------------------------------------------------- 1 | ORACLE_USERNAME = system 2 | ORACLE_PASSWORD = admin -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /Comfortaa/Comfortaa-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/Comfortaa/Comfortaa-Bold.ttf -------------------------------------------------------------------------------- /screenshots/dbmsproj-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/screenshots/dbmsproj-1.PNG -------------------------------------------------------------------------------- /screenshots/dbmsproj-2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/screenshots/dbmsproj-2.PNG -------------------------------------------------------------------------------- /screenshots/dbmsproj-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/screenshots/dbmsproj-3.PNG -------------------------------------------------------------------------------- /screenshots/dbmsproj-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/screenshots/dbmsproj-4.PNG -------------------------------------------------------------------------------- /Comfortaa/Comfortaa-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/Comfortaa/Comfortaa-Light.ttf -------------------------------------------------------------------------------- /Comfortaa/Comfortaa-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samirashoi/student-management-system/HEAD/Comfortaa/Comfortaa-Regular.ttf -------------------------------------------------------------------------------- /nbproject/private/private.properties: -------------------------------------------------------------------------------- 1 | compile.on.save=true 2 | do.depend=false 3 | do.jar=true 4 | javac.debug=true 5 | javadoc.preview=true 6 | user.properties.file=C:\\Users\\Issam\\AppData\\Roaming\\NetBeans\\8.2\\build.properties 7 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=2d1e11bb 2 | build.xml.script.CRC32=dfb18b0b 3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=2d1e11bb 7 | nbproject/build-impl.xml.script.CRC32=b855506d 8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 9 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | Swing DB StudentMS 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/dbtest/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dbtest; 7 | 8 | /** 9 | * 10 | * @author Issam 11 | */ 12 | 13 | import java.util.*; 14 | import java.util.Properties; 15 | 16 | public class Config 17 | { 18 | Properties configFile; 19 | public Config() 20 | { 21 | configFile = new java.util.Properties(); 22 | try { 23 | configFile.load(this.getClass().getResourceAsStream("..\\config.config")); 24 | }catch(Exception eta){ 25 | eta.printStackTrace(); 26 | } 27 | } 28 | 29 | public String getProperty(String key) 30 | { 31 | String value = this.configFile.getProperty(key); 32 | return value; 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /nbproject/private/private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | file:/C:/Users/Issam/Documents/NetBeansProjects/Swing%20DB%20StudentMS/src/dbtest/DeleteStudentDetails.java 7 | file:/C:/Users/Issam/Documents/NetBeansProjects/Swing%20DB%20StudentMS/src/dbtest/AddNewStudent.java 8 | file:/C:/Users/Issam/Documents/NetBeansProjects/Swing%20DB%20StudentMS/src/dbtest/ModifyStudentDetails.java 9 | file:/C:/Users/Issam/Documents/NetBeansProjects/Swing%20DB%20StudentMS/src/dbtest/Home.java 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | A simple student management system with CRUD functionalities made using Java, NetBeans IDE and Oracle as the database. 2 | 3 | This project uses a table named 'Students_Table' stored in an Oracle database to perform operations on the data. 4 | 5 | ### **Note:** 6 | * Add your Oracle database Username and Password into the 'config.config' file in order to use Oracle database in this application. 7 | 8 | * The project requires a table named 'Students_Table' to be avalable in your Oracle database. The schema is provided in the 'Students_Table.sql' file. 9 | 10 | * Sample data is provided in the 'Students_Table.sql' file. 11 | 12 | * If the fonts are not available in your system, the installation files for the fonts are available in the Comfortaa directory. 13 | 14 | ### **Sample Screenshots:** 15 | 16 | ![Home](https://github.com/samirashoi/student-management-system/blob/master/screenshots/dbmsproj-1.PNG) 17 | ![Add Student Record](https://github.com/samirashoi/student-management-system/blob/master/screenshots/dbmsproj-2.PNG) 18 | ![Update Student Record](https://github.com/samirashoi/student-management-system/blob/master/screenshots/dbmsproj-3.PNG) 19 | ![Delete Student Record](https://github.com/samirashoi/student-management-system/blob/master/screenshots/dbmsproj-4.PNG) 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=Swing DB StudentMS 7 | application.vendor=Issam 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.test.classpath=\ 23 | ${run.test.classpath} 24 | # Files in build.classes.dir which should be excluded from distribution jar 25 | dist.archive.excludes= 26 | # This directory is removed when the project is cleaned: 27 | dist.dir=dist 28 | dist.jar=${dist.dir}/Swing_DB_StudentMS.jar 29 | dist.javadoc.dir=${dist.dir}/javadoc 30 | endorsed.classpath= 31 | excludes= 32 | file.reference.jcalendar-1.4.jar=C:\\Users\\Issam\\Downloads\\Compressed\\jcalendar-1.4\\lib\\jcalendar-1.4.jar 33 | file.reference.ojdbc14.jar=C:\\Users\\Issam\\Downloads\\ojdbc14.jar 34 | includes=** 35 | jar.compress=false 36 | javac.classpath=\ 37 | ${libs.absolutelayout.classpath}:\ 38 | ${file.reference.ojdbc14.jar}:\ 39 | ${file.reference.jcalendar-1.4.jar} 40 | # Space-separated list of extra javac options 41 | javac.compilerargs= 42 | javac.deprecation=false 43 | javac.external.vm=true 44 | javac.processorpath=\ 45 | ${javac.classpath} 46 | javac.source=1.8 47 | javac.target=1.8 48 | javac.test.classpath=\ 49 | ${javac.classpath}:\ 50 | ${build.classes.dir} 51 | javac.test.processorpath=\ 52 | ${javac.test.classpath} 53 | javadoc.additionalparam= 54 | javadoc.author=false 55 | javadoc.encoding=${source.encoding} 56 | javadoc.noindex=false 57 | javadoc.nonavbar=false 58 | javadoc.notree=false 59 | javadoc.private=false 60 | javadoc.splitindex=true 61 | javadoc.use=true 62 | javadoc.version=false 63 | javadoc.windowtitle= 64 | main.class=dbtest.Home 65 | manifest.file=manifest.mf 66 | meta.inf.dir=${src.dir}/META-INF 67 | mkdist.disabled=false 68 | platform.active=default_platform 69 | run.classpath=\ 70 | ${javac.classpath}:\ 71 | ${build.classes.dir} 72 | # Space-separated list of JVM arguments used when running the project. 73 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 74 | # To set system properties for unit tests define test-sys-prop.name=value: 75 | run.jvmargs= 76 | run.test.classpath=\ 77 | ${javac.test.classpath}:\ 78 | ${build.test.classes.dir} 79 | source.encoding=UTF-8 80 | src.dir=src 81 | test.src.dir=test 82 | -------------------------------------------------------------------------------- /Comfortaa/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011 The Comfortaa Project Authors (https://github.com/alexeiva/comfortaa), with Reserved Font Name "Comfortaa". 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /Students_Table.sql: -------------------------------------------------------------------------------- 1 | create table Students_Table ( 2 | id INT, 3 | first_name VARCHAR(50), 4 | last_name VARCHAR(50), 5 | dob DATE, 6 | gender VARCHAR(50), 7 | CGPA DECIMAL(4,2), 8 | address VARCHAR(50), 9 | email VARCHAR(50) 10 | ); 11 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (1, 'Burt', 'Adshed', '09-Sep-2000', 'Male', 4.79, 'Lubomierz', 'badshed0@about.com'); 12 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (2, 'Raymund', 'Hatherleigh', '15-Jul-1999', 'Male', 5.76, 'Longbei', 'rhatherleigh1@xrea.com'); 13 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (3, 'Cindelyn', 'McGurn', '12-Feb-2000', 'Female', 5.71, 'Shu', 'cmcgurn2@ycombinator.com'); 14 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (4, 'Freddy', 'Dyche', '19-Sep-1999', 'Male', 2.37, 'Beringinjaya', 'fdyche3@wikimedia.org'); 15 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (5, 'Lon', 'Guilloud', '27-Dec-1999', 'Male', 2.24, 'Guilmaro', 'lguilloud4@people.com.cn'); 16 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (6, 'Veronica', 'Dawdary', '05-Apr-1999', 'Female', 8.9, 'Foz Giraldo', 'vdawdary5@newyorker.com'); 17 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (7, 'Patrizius', 'Farmloe', '14-Jun-1997', 'Male', 3.25, 'Villefranche-sur-Mer', 'pfarmloe6@blogger.com'); 18 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (8, 'Ambrosio', 'Shayler', '04-Sep-2000', 'Male', 5.03, 'Węgierska Górka', 'ashayler7@w3.org'); 19 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (9, 'Myca', 'Daugherty', '14-Jun-1998', 'Male', 2.78, 'Kuršumlija', 'mdaugherty8@smh.com.au'); 20 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (10, 'Rebe', 'Aldus', '25-Oct-1996', 'Female', 9.77, 'Pacaembu', 'raldus9@delicious.com'); 21 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (11, 'Joela', 'Broz', '25-Jan-1997', 'Female', 5.35, 'Debark’', 'jbroza@google.com.au'); 22 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (12, 'Dana', 'McCluney', '03-Apr-2000', 'Male', 1.17, 'Tianya', 'dmccluneyb@wufoo.com'); 23 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (13, 'Alejandrina', 'Paver', '29-Oct-1997', 'Female', 8.85, 'Santai', 'apaverc@youtube.com'); 24 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (14, 'Agnella', 'Halford', '15-Jan-1997', 'Female', 3.94, 'Ouésso', 'ahalfordd@surveymonkey.com'); 25 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (15, 'Clerissa', 'Simak', '22-Jan-1997', 'Female', 7.32, 'Det Udom', 'csimake@nifty.com'); 26 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (16, 'Ermengarde', 'Wixon', '09-Nov-1999', 'Female', 2.74, 'Tečovice', 'ewixonf@usa.gov'); 27 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (17, 'Moore', 'Basnett', '03-Mar-1997', 'Male', 2.42, 'Orosh', 'mbasnettg@nba.com'); 28 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (18, 'Rabbi', 'Pickervance', '22-Jul-1999', 'Male', 9.25, 'Aubagne', 'rpickervanceh@rakuten.co.jp'); 29 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (19, 'Tisha', 'Chesshire', '05-Nov-1997', 'Female', 5.65, 'San Cristóbal Totonicapán', 'tchesshirei@free.fr'); 30 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (20, 'Samson', 'Dumbleton', '30-Dec-1996', 'Male', 4.04, 'Villa Hayes', 'sdumbletonj@hp.com'); 31 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (21, 'Giordano', 'Barnewall', '26-May-2000', 'Male', 1.52, 'Limit', 'gbarnewallk@army.mil'); 32 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (22, 'Liane', 'Mulgrew', '24-Dec-1999', 'Female', 3.5, 'Bailianhe', 'lmulgrewl@pbs.org'); 33 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (23, 'Bryanty', 'Jenney', '01-Dec-1999', 'Male', 9.35, 'Sąspów', 'bjenneym@ca.gov'); 34 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (24, 'Allison', 'Newbigging', '12-Jan-1997', 'Female', 1.19, 'A Yun Pa', 'anewbiggingn@bbc.co.uk'); 35 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (25, 'Iago', 'Summerill', '07-Mar-1998', 'Male', 3.21, 'Liopétri', 'isummerillo@1688.com'); 36 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (26, 'Michal', 'Cherm', '10-Feb-2000', 'Male', 5.83, 'Kamimaruko', 'mchermp@hexun.com'); 37 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (27, 'Cristiano', 'Gartell', '08-Nov-1997', 'Male', 9.35, 'Polo', 'cgartellq@google.nl'); 38 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (28, 'Constance', 'Holleran', '12-Nov-1998', 'Female', 6.01, 'Gif-sur-Yvette', 'cholleranr@usa.gov'); 39 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (29, 'Stoddard', 'Webburn', '10-Sep-2000', 'Female', 7.36, 'Sadek', 'swebburns@zimbio.com'); 40 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (30, 'Merci', 'Savidge', '19-Aug-1997', 'Female', 6.11, 'Tanggung', 'msavidget@weather.com'); 41 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (31, 'Lauraine', 'Sangster', '15-Feb-1998', 'Female', 3.18, 'Esmeraldas', 'lsangsteru@mlb.com'); 42 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (32, 'Elnar', 'Piercey', '20-Nov-1999', 'Male', 1.55, 'Pensacola', 'epierceyv@wordpress.com'); 43 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (33, 'Orson', 'Orwell', '30-Mar-1997', 'Male', 4.29, 'Wangyi Zhendian', 'oorwellw@so-net.ne.jp'); 44 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (34, 'Adelle', 'Busswell', '16-Jul-2000', 'Female', 6.22, 'Tsibulev', 'abusswellx@usgs.gov'); 45 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (35, 'Joseito', 'Dacey', '24-Feb-1997', 'Male', 2.9, 'Yirga ‘Alem', 'jdaceyy@msn.com'); 46 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (36, 'Sabina', 'McCallister', '03-Jun-1998', 'Female', 4.18, 'Ilovka', 'smccallisterz@miitbeian.gov.cn'); 47 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (37, 'Idelle', 'Lapworth', '10-Aug-2000', 'Female', 9.32, 'Buenos Aires', 'ilapworth10@engadget.com'); 48 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (38, 'Gustave', 'Fouracres', '26-Feb-1997', 'Male', 5.92, 'Shawnee Mission', 'gfouracres11@51.la'); 49 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (39, 'Celine', 'O''Fihily', '03-Sep-1999', 'Female', 5.52, 'Turija', 'cofihily12@shop-pro.jp'); 50 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (40, 'Tammi', 'Goldes', '16-May-2000', 'Female', 2.26, 'Yezhi', 'tgoldes13@wikimedia.org'); 51 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (41, 'Rudolf', 'Ward', '29-Apr-1997', 'Male', 6.69, 'Shatian', 'rward14@live.com'); 52 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (42, 'Base', 'Dangerfield', '20-Feb-2000', 'Male', 1.3, 'Penza', 'bdangerfield15@cocolog-nifty.com'); 53 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (43, 'Olga', 'Simeoni', '04-Sep-2000', 'Female', 3.27, 'Kiihtelysvaara', 'osimeoni16@sciencedirect.com'); 54 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (44, 'Pepe', 'Throssell', '13-May-1998', 'Male', 6.11, 'Kosti', 'pthrossell17@liveinternet.ru'); 55 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (45, 'Barnie', 'Hallibone', '08-Apr-1998', 'Male', 6.65, 'Mölndal', 'bhallibone18@joomla.org'); 56 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (46, 'Sterne', 'Boldra', '09-Feb-1999', 'Male', 8.26, 'Shuigou’ao', 'sboldra19@bloglines.com'); 57 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (47, 'Ephrayim', 'Reedshaw', '28-Apr-2000', 'Male', 6.39, 'Ágios Efstrátios', 'ereedshaw1a@google.it'); 58 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (48, 'Aleta', 'Horrod', '08-Dec-1999', 'Female', 1.19, 'Kuching', 'ahorrod1b@craigslist.org'); 59 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (49, 'Leon', 'Dolohunty', '13-Aug-2000', 'Male', 8.88, 'Issad', 'ldolohunty1c@cargocollective.com'); 60 | insert into Students_Table (id, first_name, last_name, dob, gender, CGPA, address, email) values (50, 'Bertrando', 'Kitchenside', '28-Oct-1998', 'Male', 5.5, 'Jingdezhen', 'bkitchenside1d@slashdot.org'); 61 | -------------------------------------------------------------------------------- /src/dbtest/AddNewStudent.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | -------------------------------------------------------------------------------- /src/dbtest/DeleteStudentDetails.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /src/dbtest/ModifyStudentDetails.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | -------------------------------------------------------------------------------- /src/dbtest/Home.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dbtest; 7 | 8 | 9 | import java.sql.*; 10 | import javax.swing.table.DefaultTableModel; 11 | 12 | /** 13 | * 14 | * @author Issam 15 | */ 16 | public class Home extends javax.swing.JFrame { 17 | 18 | /** 19 | * Creates new form Home 20 | */ 21 | public Home() { 22 | initComponents(); 23 | } 24 | 25 | void loadData(){ 26 | try{ 27 | //step1 load the driver class 28 | Class.forName("oracle.jdbc.driver.OracleDriver"); 29 | //step2 create the connection object 30 | Config cfg = new Config(); 31 | String user = cfg.getProperty("ORACLE_USERNAME"); 32 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 33 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 34 | System.out.println("In loadSampleData()"); 35 | //step3 create the statement object 36 | Statement stmt=con.createStatement(); 37 | 38 | //step4 execute query 39 | ResultSet rs=stmt.executeQuery("select * from Students_Table"); 40 | 41 | while(jTable1.getRowCount() > 0) 42 | { 43 | 44 | ((DefaultTableModel)jTable1.getModel()).removeRow(0); 45 | } 46 | 47 | int col = rs.getMetaData().getColumnCount(); 48 | // System.out.println("No. of columns: " + col); 49 | 50 | while(rs.next()){ 51 | Object[] rows = new Object[col]; 52 | for(int i=1; i <= col; i++){ 53 | rows[i-1] = rs.getObject(i); 54 | } 55 | ((DefaultTableModel)jTable1.getModel()).insertRow(rs.getRow()-1,rows); 56 | } 57 | //step5 close the connection object 58 | rs.close(); 59 | stmt.close(); 60 | con.close(); 61 | 62 | }catch(Exception e){ System.out.println(e);} 63 | 64 | } 65 | 66 | /** 67 | * This method is called from within the constructor to initialize the form. 68 | * WARNING: Do NOT modify this code. The content of this method is always 69 | * regenerated by the Form Editor. 70 | */ 71 | @SuppressWarnings("unchecked") 72 | // //GEN-BEGIN:initComponents 73 | private void initComponents() { 74 | 75 | jPanel1 = new javax.swing.JPanel(); 76 | jPanel2 = new javax.swing.JPanel(); 77 | jButton1 = new javax.swing.JButton(); 78 | jLabel1 = new javax.swing.JLabel(); 79 | jButton2 = new javax.swing.JButton(); 80 | jButton3 = new javax.swing.JButton(); 81 | jButton4 = new javax.swing.JButton(); 82 | jPanel3 = new javax.swing.JPanel(); 83 | jScrollPane1 = new javax.swing.JScrollPane(); 84 | jTable1 = new javax.swing.JTable(); 85 | jLabel2 = new javax.swing.JLabel(); 86 | 87 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 88 | setUndecorated(true); 89 | addWindowFocusListener(new java.awt.event.WindowFocusListener() { 90 | public void windowGainedFocus(java.awt.event.WindowEvent evt) { 91 | formWindowGainedFocus(evt); 92 | } 93 | public void windowLostFocus(java.awt.event.WindowEvent evt) { 94 | } 95 | }); 96 | 97 | jPanel2.setBackground(new java.awt.Color(255, 204, 153)); 98 | jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 10, true)); 99 | 100 | jButton1.setBackground(new java.awt.Color(255, 153, 153)); 101 | jButton1.setFont(new java.awt.Font("Comfortaa Light", 1, 14)); // NOI18N 102 | jButton1.setForeground(new java.awt.Color(0, 51, 51)); 103 | jButton1.setMnemonic('v'); 104 | jButton1.setText("View Student Database"); 105 | jButton1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true)); 106 | jButton1.addMouseListener(new java.awt.event.MouseAdapter() { 107 | public void mousePressed(java.awt.event.MouseEvent evt) { 108 | jButton1MousePressed(evt); 109 | } 110 | }); 111 | jButton1.addActionListener(new java.awt.event.ActionListener() { 112 | public void actionPerformed(java.awt.event.ActionEvent evt) { 113 | jButton1ActionPerformed(evt); 114 | } 115 | }); 116 | 117 | jLabel1.setFont(new java.awt.Font("Comfortaa", 1, 20)); // NOI18N 118 | jLabel1.setText("Student Management System"); 119 | 120 | jButton2.setBackground(new java.awt.Color(255, 153, 153)); 121 | jButton2.setFont(new java.awt.Font("Comfortaa Light", 1, 14)); // NOI18N 122 | jButton2.setForeground(new java.awt.Color(0, 51, 51)); 123 | jButton2.setMnemonic('a'); 124 | jButton2.setText("Add Student Details"); 125 | jButton2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true)); 126 | jButton2.addActionListener(new java.awt.event.ActionListener() { 127 | public void actionPerformed(java.awt.event.ActionEvent evt) { 128 | jButton2ActionPerformed(evt); 129 | } 130 | }); 131 | 132 | jButton3.setBackground(new java.awt.Color(255, 153, 153)); 133 | jButton3.setFont(new java.awt.Font("Comfortaa Light", 1, 14)); // NOI18N 134 | jButton3.setForeground(new java.awt.Color(0, 51, 51)); 135 | jButton3.setMnemonic('u'); 136 | jButton3.setText("Update Student Details"); 137 | jButton3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true)); 138 | jButton3.addActionListener(new java.awt.event.ActionListener() { 139 | public void actionPerformed(java.awt.event.ActionEvent evt) { 140 | jButton3ActionPerformed(evt); 141 | } 142 | }); 143 | 144 | jButton4.setBackground(new java.awt.Color(255, 153, 153)); 145 | jButton4.setFont(new java.awt.Font("Comfortaa Light", 1, 14)); // NOI18N 146 | jButton4.setForeground(new java.awt.Color(0, 51, 51)); 147 | jButton4.setMnemonic('d'); 148 | jButton4.setText("Delete Student Details"); 149 | jButton4.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true)); 150 | jButton4.addActionListener(new java.awt.event.ActionListener() { 151 | public void actionPerformed(java.awt.event.ActionEvent evt) { 152 | jButton4ActionPerformed(evt); 153 | } 154 | }); 155 | 156 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); 157 | jPanel2.setLayout(jPanel2Layout); 158 | jPanel2Layout.setHorizontalGroup( 159 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 160 | .addGroup(jPanel2Layout.createSequentialGroup() 161 | .addContainerGap() 162 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 163 | .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 164 | .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 165 | .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 166 | .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 167 | .addContainerGap()) 168 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() 169 | .addContainerGap(37, Short.MAX_VALUE) 170 | .addComponent(jLabel1) 171 | .addGap(28, 28, 28)) 172 | ); 173 | jPanel2Layout.setVerticalGroup( 174 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 175 | .addGroup(jPanel2Layout.createSequentialGroup() 176 | .addGap(64, 64, 64) 177 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE) 178 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 179 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) 180 | .addGap(18, 18, 18) 181 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) 182 | .addGap(18, 18, 18) 183 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) 184 | .addGap(18, 18, 18) 185 | .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) 186 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 187 | ); 188 | 189 | jPanel3.setBackground(new java.awt.Color(255, 204, 51)); 190 | jPanel3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 10, true)); 191 | 192 | jTable1.setFont(new java.awt.Font("Dubai", 0, 12)); // NOI18N 193 | jTable1.setModel(new javax.swing.table.DefaultTableModel( 194 | new Object [][] { 195 | 196 | }, 197 | new String [] { 198 | "ID", "FIRST_NAME", "LAST_NAME", "DOB", "GENDER", "CGPA", "ADDRESS", "EMAIL" 199 | } 200 | ) { 201 | Class[] types = new Class [] { 202 | java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.Float.class, java.lang.String.class, java.lang.String.class 203 | }; 204 | boolean[] canEdit = new boolean [] { 205 | false, false, false, false, false, false, false, false 206 | }; 207 | 208 | public Class getColumnClass(int columnIndex) { 209 | return types [columnIndex]; 210 | } 211 | 212 | public boolean isCellEditable(int rowIndex, int columnIndex) { 213 | return canEdit [columnIndex]; 214 | } 215 | }); 216 | jTable1.setGridColor(new java.awt.Color(255, 255, 255)); 217 | jTable1.setIntercellSpacing(new java.awt.Dimension(10, 10)); 218 | jTable1.setRowHeight(20); 219 | jTable1.getTableHeader().setReorderingAllowed(false); 220 | jScrollPane1.setViewportView(jTable1); 221 | if (jTable1.getColumnModel().getColumnCount() > 0) { 222 | jTable1.getColumnModel().getColumn(0).setResizable(false); 223 | } 224 | 225 | javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); 226 | jPanel3.setLayout(jPanel3Layout); 227 | jPanel3Layout.setHorizontalGroup( 228 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 229 | .addGroup(jPanel3Layout.createSequentialGroup() 230 | .addContainerGap() 231 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 725, Short.MAX_VALUE) 232 | .addContainerGap()) 233 | ); 234 | jPanel3Layout.setVerticalGroup( 235 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 236 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() 237 | .addContainerGap(16, Short.MAX_VALUE) 238 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 540, javax.swing.GroupLayout.PREFERRED_SIZE) 239 | .addContainerGap()) 240 | ); 241 | 242 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 243 | jPanel1.setLayout(jPanel1Layout); 244 | jPanel1Layout.setHorizontalGroup( 245 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 246 | .addGroup(jPanel1Layout.createSequentialGroup() 247 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 248 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 249 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 250 | .addContainerGap(27, Short.MAX_VALUE)) 251 | ); 252 | jPanel1Layout.setVerticalGroup( 253 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 254 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 255 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) 256 | .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 257 | .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 258 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 259 | ); 260 | 261 | jLabel2.setFont(new java.awt.Font("Verdana", 1, 20)); // NOI18N 262 | jLabel2.setText("X"); 263 | jLabel2.addMouseListener(new java.awt.event.MouseAdapter() { 264 | public void mousePressed(java.awt.event.MouseEvent evt) { 265 | jLabel2MousePressed(evt); 266 | } 267 | }); 268 | 269 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 270 | getContentPane().setLayout(layout); 271 | layout.setHorizontalGroup( 272 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 273 | .addGroup(layout.createSequentialGroup() 274 | .addGap(48, 48, 48) 275 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 276 | .addContainerGap()) 277 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 278 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 279 | .addComponent(jLabel2) 280 | .addGap(51, 51, 51)) 281 | ); 282 | layout.setVerticalGroup( 283 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 284 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 285 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 286 | .addComponent(jLabel2) 287 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 288 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 289 | .addGap(35, 35, 35)) 290 | ); 291 | 292 | pack(); 293 | }// //GEN-END:initComponents 294 | 295 | private void jButton1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MousePressed 296 | // TODO add your handling code here: 297 | loadData(); 298 | }//GEN-LAST:event_jButton1MousePressed 299 | 300 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 301 | // TODO add your handling code here: 302 | loadData(); 303 | }//GEN-LAST:event_jButton1ActionPerformed 304 | 305 | private void jLabel2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MousePressed 306 | // TODO add your handling code here: 307 | System.exit(0); 308 | }//GEN-LAST:event_jLabel2MousePressed 309 | 310 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed 311 | // TODO add your handling code here: 312 | //ADD STUDENT RECORD 313 | AddNewStudent s = new AddNewStudent(); 314 | s.setVisible(true); 315 | }//GEN-LAST:event_jButton2ActionPerformed 316 | 317 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed 318 | // TODO add your handling code here: 319 | ModifyStudentDetails s = new ModifyStudentDetails(); 320 | s.setVisible(true); 321 | }//GEN-LAST:event_jButton3ActionPerformed 322 | 323 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed 324 | // TODO add your handling code here: 325 | DeleteStudentDetails s = new DeleteStudentDetails(); 326 | s.setVisible(true); 327 | }//GEN-LAST:event_jButton4ActionPerformed 328 | 329 | private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus 330 | // TODO add your handling code here: 331 | loadData(); 332 | }//GEN-LAST:event_formWindowGainedFocus 333 | 334 | /** 335 | * @param args the command line arguments 336 | */ 337 | public static void main(String args[]) { 338 | /* Set the Nimbus look and feel */ 339 | // 340 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 341 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 342 | */ 343 | try { 344 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 345 | if ("Windows".equals(info.getName())) { 346 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 347 | break; 348 | } 349 | } 350 | } catch (ClassNotFoundException ex) { 351 | java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 352 | } catch (InstantiationException ex) { 353 | java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 354 | } catch (IllegalAccessException ex) { 355 | java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 356 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 357 | java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 358 | } 359 | // 360 | 361 | /* Create and display the form */ 362 | java.awt.EventQueue.invokeLater(new Runnable() { 363 | public void run() { 364 | new Home().setVisible(true); 365 | } 366 | }); 367 | } 368 | 369 | // Variables declaration - do not modify//GEN-BEGIN:variables 370 | private javax.swing.JButton jButton1; 371 | private javax.swing.JButton jButton2; 372 | private javax.swing.JButton jButton3; 373 | private javax.swing.JButton jButton4; 374 | private javax.swing.JLabel jLabel1; 375 | private javax.swing.JLabel jLabel2; 376 | private javax.swing.JPanel jPanel1; 377 | private javax.swing.JPanel jPanel2; 378 | private javax.swing.JPanel jPanel3; 379 | private javax.swing.JScrollPane jScrollPane1; 380 | private javax.swing.JTable jTable1; 381 | // End of variables declaration//GEN-END:variables 382 | } 383 | -------------------------------------------------------------------------------- /src/dbtest/AddNewStudent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dbtest; 7 | 8 | import java.sql.*; 9 | import java.sql.DriverManager; 10 | import java.sql.PreparedStatement; 11 | import java.util.regex.Pattern; 12 | import java.util.Date; 13 | import javax.swing.JOptionPane; 14 | 15 | /** 16 | * 17 | * @author Issam 18 | */ 19 | public class AddNewStudent extends javax.swing.JFrame{ 20 | 21 | /** 22 | * Creates new form AddNewStudent 23 | */ 24 | public AddNewStudent() { 25 | initComponents(); 26 | } 27 | public static boolean isEmailValid(String email) 28 | { 29 | String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\."+ 30 | "[a-zA-Z0-9_+&*-]+)*@" + 31 | "(?:[a-zA-Z0-9-]+\\.)+[a-z" + 32 | "A-Z]{2,7}$"; 33 | 34 | Pattern pat = Pattern.compile(emailRegex); 35 | if (email == null) 36 | return false; 37 | return pat.matcher(email).matches(); 38 | } 39 | /** 40 | * This method is called from within the constructor to initialize the form. 41 | * WARNING: Do NOT modify this code. The content of this method is always 42 | * regenerated by the Form Editor. 43 | */ 44 | @SuppressWarnings("unchecked") 45 | // //GEN-BEGIN:initComponents 46 | private void initComponents() { 47 | 48 | jPanel1 = new javax.swing.JPanel(); 49 | jLabel1 = new javax.swing.JLabel(); 50 | jLabel2 = new javax.swing.JLabel(); 51 | jTextField1 = new javax.swing.JTextField(); 52 | jLabel3 = new javax.swing.JLabel(); 53 | jLabel4 = new javax.swing.JLabel(); 54 | jLabel5 = new javax.swing.JLabel(); 55 | jLabel6 = new javax.swing.JLabel(); 56 | jLabel7 = new javax.swing.JLabel(); 57 | jLabel8 = new javax.swing.JLabel(); 58 | jTextField2 = new javax.swing.JTextField(); 59 | jComboBox1 = new javax.swing.JComboBox<>(); 60 | jTextField3 = new javax.swing.JTextField(); 61 | jTextField4 = new javax.swing.JTextField(); 62 | jTextField5 = new javax.swing.JTextField(); 63 | jDateChooser1 = new com.toedter.calendar.JDateChooser(); 64 | jButton1 = new javax.swing.JButton(); 65 | jLabel9 = new javax.swing.JLabel(); 66 | jTextField6 = new javax.swing.JTextField(); 67 | 68 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 69 | 70 | jLabel1.setFont(new java.awt.Font("Comfortaa", 1, 20)); // NOI18N 71 | jLabel1.setText("Add Student Details"); 72 | 73 | jLabel2.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 74 | jLabel2.setText("First Name"); 75 | 76 | jTextField1.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 77 | jTextField1.setToolTipText("Enter First Name"); 78 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 79 | public void actionPerformed(java.awt.event.ActionEvent evt) { 80 | jTextField1ActionPerformed(evt); 81 | } 82 | }); 83 | 84 | jLabel3.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 85 | jLabel3.setText("Last Name"); 86 | 87 | jLabel4.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 88 | jLabel4.setText("DOB"); 89 | 90 | jLabel5.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 91 | jLabel5.setText("Gender"); 92 | 93 | jLabel6.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 94 | jLabel6.setText("CGPA"); 95 | 96 | jLabel7.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 97 | jLabel7.setText("Email"); 98 | 99 | jLabel8.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 100 | jLabel8.setText("Address"); 101 | 102 | jTextField2.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 103 | jTextField2.setToolTipText("Enter Last Name"); 104 | jTextField2.addActionListener(new java.awt.event.ActionListener() { 105 | public void actionPerformed(java.awt.event.ActionEvent evt) { 106 | jTextField2ActionPerformed(evt); 107 | } 108 | }); 109 | 110 | jComboBox1.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 111 | jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Male", "Female" })); 112 | jComboBox1.addActionListener(new java.awt.event.ActionListener() { 113 | public void actionPerformed(java.awt.event.ActionEvent evt) { 114 | jComboBox1ActionPerformed(evt); 115 | } 116 | }); 117 | 118 | jTextField3.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 119 | jTextField3.setToolTipText("Enter CGPA"); 120 | 121 | jTextField4.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 122 | jTextField4.setToolTipText("Enter Address"); 123 | 124 | jTextField5.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 125 | jTextField5.setToolTipText("Enter Email Address"); 126 | 127 | jDateChooser1.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 128 | 129 | jButton1.setFont(new java.awt.Font("Comfortaa", 0, 14)); // NOI18N 130 | jButton1.setText("Add New Record"); 131 | jButton1.addActionListener(new java.awt.event.ActionListener() { 132 | public void actionPerformed(java.awt.event.ActionEvent evt) { 133 | jButton1ActionPerformed(evt); 134 | } 135 | }); 136 | 137 | jLabel9.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 138 | jLabel9.setText("ID"); 139 | 140 | jTextField6.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 141 | jTextField6.addActionListener(new java.awt.event.ActionListener() { 142 | public void actionPerformed(java.awt.event.ActionEvent evt) { 143 | jTextField6ActionPerformed(evt); 144 | } 145 | }); 146 | 147 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 148 | jPanel1.setLayout(jPanel1Layout); 149 | jPanel1Layout.setHorizontalGroup( 150 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 151 | .addGroup(jPanel1Layout.createSequentialGroup() 152 | .addGap(157, 157, 157) 153 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE) 154 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 155 | .addGroup(jPanel1Layout.createSequentialGroup() 156 | .addGap(106, 106, 106) 157 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 158 | .addComponent(jLabel3) 159 | .addComponent(jLabel2) 160 | .addComponent(jLabel4) 161 | .addComponent(jLabel5) 162 | .addComponent(jLabel6) 163 | .addComponent(jLabel8) 164 | .addComponent(jLabel7) 165 | .addComponent(jLabel9)) 166 | .addGap(64, 64, 64) 167 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 168 | .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING) 169 | .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 170 | .addComponent(jDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE) 171 | .addComponent(jTextField4) 172 | .addComponent(jTextField3) 173 | .addComponent(jTextField2) 174 | .addComponent(jTextField5) 175 | .addComponent(jTextField6)) 176 | .addGap(100, 100, 100)) 177 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 178 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 179 | .addComponent(jLabel1) 180 | .addGap(135, 135, 135)) 181 | ); 182 | jPanel1Layout.setVerticalGroup( 183 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 184 | .addGroup(jPanel1Layout.createSequentialGroup() 185 | .addContainerGap() 186 | .addComponent(jLabel1) 187 | .addGap(18, 18, 18) 188 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 189 | .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 190 | .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 191 | .addGap(1, 1, 1) 192 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 193 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) 194 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 195 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 196 | .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE) 197 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 198 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 199 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 200 | .addComponent(jLabel4) 201 | .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 202 | .addGap(29, 29, 29) 203 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 204 | .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 205 | .addGroup(jPanel1Layout.createSequentialGroup() 206 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 207 | .addComponent(jLabel5) 208 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 209 | .addGap(30, 30, 30) 210 | .addComponent(jLabel6))) 211 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 212 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 213 | .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE) 214 | .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 215 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 216 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 217 | .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) 218 | .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 219 | .addGap(32, 32, 32) 220 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 221 | .addContainerGap(70, Short.MAX_VALUE)) 222 | ); 223 | 224 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 225 | getContentPane().setLayout(layout); 226 | layout.setHorizontalGroup( 227 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 228 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 229 | ); 230 | layout.setVerticalGroup( 231 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 232 | .addGroup(layout.createSequentialGroup() 233 | .addContainerGap() 234 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 235 | ); 236 | 237 | pack(); 238 | }// //GEN-END:initComponents 239 | 240 | private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed 241 | // TODO add your handling code here: 242 | }//GEN-LAST:event_jTextField2ActionPerformed 243 | 244 | private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed 245 | // TODO add your handling code here: 246 | }//GEN-LAST:event_jComboBox1ActionPerformed 247 | 248 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed 249 | // TODO add your handling code here: 250 | }//GEN-LAST:event_jTextField1ActionPerformed 251 | 252 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 253 | // TODO add your handling code here: 254 | Integer id = Integer.parseInt(jTextField6.getText()); 255 | String fname = jTextField1.getText(); 256 | String lname = jTextField2.getText(); 257 | Date dob = new java.sql.Date(jDateChooser1.getDate().getTime()); 258 | String gender = jComboBox1.getSelectedItem().toString(); 259 | Double cgpa = Double.parseDouble(jTextField3.getText()); 260 | String address = jTextField4.getText(); 261 | String email = jTextField5.getText(); 262 | try{ 263 | if(!isEmailValid(email)){ 264 | throw new Exception("Invalid Email Address"); 265 | } 266 | if(cgpa<0 || cgpa>10){ 267 | throw new Exception("Invalid CGPA"); 268 | } 269 | long timeNow = new java.util.Date().getTime(); 270 | if(dob.getTime() > timeNow){ 271 | throw new Exception("Invalid Date of Birth"); 272 | } 273 | 274 | 275 | if(isEmailValid(email) && (cgpa >= 0 && cgpa <= 10) && (dob.getTime() < timeNow)){ 276 | 277 | //step1 load the driver class 278 | Class.forName("oracle.jdbc.driver.OracleDriver"); 279 | 280 | //step2 create the connection object 281 | Config cfg = new Config(); 282 | String user = cfg.getProperty("ORACLE_USERNAME"); 283 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 284 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 285 | //step3 create the statement object 286 | PreparedStatement stmt=con.prepareStatement("insert into Students_Table (id,first_name, last_name, dob, gender, CGPA, address, email) values(?,?,?,?,?,?,?,?)"); 287 | //step4 execute query 288 | 289 | stmt.setInt(1, id); 290 | stmt.setString(2,fname); 291 | stmt.setString(3,lname); 292 | stmt.setDate(4,new java.sql.Date(dob.getTime())); 293 | stmt.setString(5,gender); 294 | stmt.setDouble(6,cgpa); 295 | stmt.setString(7,address); 296 | stmt.setString(8, email); 297 | 298 | // System.out.println(stmt.toString()); 299 | 300 | int i=stmt.executeUpdate(); 301 | String str = i+" records inserted"; 302 | System.out.println(str); 303 | JOptionPane.showMessageDialog(null,str); 304 | con.close(); 305 | 306 | jTextField1.setText(null); 307 | jTextField2.setText(null); 308 | jDateChooser1.setDate(null); 309 | jComboBox1.setSelectedItem(null); 310 | jTextField3.setText(null); 311 | jTextField4.setText(null); 312 | jTextField5.setText(null); 313 | jTextField6.setText(null); 314 | } 315 | }catch(Exception e){ System.out.println(e);JOptionPane.showMessageDialog(null,e.toString());} 316 | 317 | 318 | }//GEN-LAST:event_jButton1ActionPerformed 319 | 320 | private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed 321 | // TODO add your handling code here: 322 | }//GEN-LAST:event_jTextField6ActionPerformed 323 | 324 | /** 325 | * @param args the command line arguments 326 | */ 327 | public static void main(String args[]) { 328 | /* Set the Nimbus look and feel */ 329 | // 330 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 331 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 332 | */ 333 | try { 334 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 335 | if ("Nimbus".equals(info.getName())) { 336 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 337 | break; 338 | } 339 | } 340 | } catch (ClassNotFoundException ex) { 341 | java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 342 | } catch (InstantiationException ex) { 343 | java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 344 | } catch (IllegalAccessException ex) { 345 | java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 346 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 347 | java.util.logging.Logger.getLogger(AddNewStudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 348 | } 349 | // 350 | 351 | /* Create and display the form */ 352 | java.awt.EventQueue.invokeLater(new Runnable() { 353 | public void run() { 354 | new AddNewStudent().setVisible(true); 355 | } 356 | }); 357 | } 358 | 359 | // Variables declaration - do not modify//GEN-BEGIN:variables 360 | private javax.swing.JButton jButton1; 361 | private javax.swing.JComboBox jComboBox1; 362 | private com.toedter.calendar.JDateChooser jDateChooser1; 363 | private javax.swing.JLabel jLabel1; 364 | private javax.swing.JLabel jLabel2; 365 | private javax.swing.JLabel jLabel3; 366 | private javax.swing.JLabel jLabel4; 367 | private javax.swing.JLabel jLabel5; 368 | private javax.swing.JLabel jLabel6; 369 | private javax.swing.JLabel jLabel7; 370 | private javax.swing.JLabel jLabel8; 371 | private javax.swing.JLabel jLabel9; 372 | private javax.swing.JPanel jPanel1; 373 | private javax.swing.JTextField jTextField1; 374 | private javax.swing.JTextField jTextField2; 375 | private javax.swing.JTextField jTextField3; 376 | private javax.swing.JTextField jTextField4; 377 | private javax.swing.JTextField jTextField5; 378 | private javax.swing.JTextField jTextField6; 379 | // End of variables declaration//GEN-END:variables 380 | } 381 | -------------------------------------------------------------------------------- /src/dbtest/DeleteStudentDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dbtest; 7 | 8 | import java.sql.Connection; 9 | import java.sql.Date; 10 | import java.sql.DriverManager; 11 | import java.sql.PreparedStatement; 12 | import java.sql.ResultSet; 13 | import javax.swing.JOptionPane; 14 | 15 | /** 16 | * 17 | * @author Issam 18 | */ 19 | public class DeleteStudentDetails extends javax.swing.JFrame { 20 | 21 | /** 22 | * Creates new form DeleteStudentDetails 23 | */ 24 | public DeleteStudentDetails() { 25 | initComponents(); 26 | } 27 | 28 | /** 29 | * This method is called from within the constructor to initialize the form. 30 | * WARNING: Do NOT modify this code. The content of this method is always 31 | * regenerated by the Form Editor. 32 | */ 33 | @SuppressWarnings("unchecked") 34 | // //GEN-BEGIN:initComponents 35 | private void initComponents() { 36 | 37 | jPanel1 = new javax.swing.JPanel(); 38 | jLabel1 = new javax.swing.JLabel(); 39 | jButton1 = new javax.swing.JButton(); 40 | jLabel9 = new javax.swing.JLabel(); 41 | jTextField6 = new javax.swing.JTextField(); 42 | jLabel2 = new javax.swing.JLabel(); 43 | jLabel3 = new javax.swing.JLabel(); 44 | jLabel4 = new javax.swing.JLabel(); 45 | jLabel5 = new javax.swing.JLabel(); 46 | jLabel6 = new javax.swing.JLabel(); 47 | jLabel8 = new javax.swing.JLabel(); 48 | jLabel7 = new javax.swing.JLabel(); 49 | jLabel10 = new javax.swing.JLabel(); 50 | jLabel11 = new javax.swing.JLabel(); 51 | jLabel12 = new javax.swing.JLabel(); 52 | jLabel13 = new javax.swing.JLabel(); 53 | jLabel14 = new javax.swing.JLabel(); 54 | jLabel15 = new javax.swing.JLabel(); 55 | jLabel16 = new javax.swing.JLabel(); 56 | 57 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 58 | 59 | jLabel1.setFont(new java.awt.Font("Comfortaa", 1, 20)); // NOI18N 60 | jLabel1.setText("Delete Student Details"); 61 | 62 | jButton1.setFont(new java.awt.Font("Comfortaa", 0, 14)); // NOI18N 63 | jButton1.setText("Delete Student Record"); 64 | jButton1.addActionListener(new java.awt.event.ActionListener() { 65 | public void actionPerformed(java.awt.event.ActionEvent evt) { 66 | jButton1ActionPerformed(evt); 67 | } 68 | }); 69 | 70 | jLabel9.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 71 | jLabel9.setText("Student ID"); 72 | 73 | jTextField6.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 74 | jTextField6.setToolTipText("Enter SID of Student to be removed"); 75 | jTextField6.addActionListener(new java.awt.event.ActionListener() { 76 | public void actionPerformed(java.awt.event.ActionEvent evt) { 77 | jTextField6ActionPerformed(evt); 78 | } 79 | }); 80 | jTextField6.addKeyListener(new java.awt.event.KeyAdapter() { 81 | public void keyReleased(java.awt.event.KeyEvent evt) { 82 | jTextField6KeyReleased(evt); 83 | } 84 | }); 85 | 86 | jLabel2.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 87 | jLabel2.setText("First Name"); 88 | 89 | jLabel3.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 90 | jLabel3.setText("Last Name"); 91 | 92 | jLabel4.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 93 | jLabel4.setText("DOB"); 94 | 95 | jLabel5.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 96 | jLabel5.setText("Gender"); 97 | 98 | jLabel6.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 99 | jLabel6.setText("CGPA"); 100 | 101 | jLabel8.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 102 | jLabel8.setText("Address"); 103 | 104 | jLabel7.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 105 | jLabel7.setText("Email"); 106 | 107 | jLabel10.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 108 | jLabel10.setText("None"); 109 | 110 | jLabel11.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 111 | jLabel11.setText("None"); 112 | 113 | jLabel12.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 114 | jLabel12.setText("??-??-????"); 115 | 116 | jLabel13.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 117 | jLabel13.setText("None"); 118 | 119 | jLabel14.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 120 | jLabel14.setText("0.00"); 121 | 122 | jLabel15.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 123 | jLabel15.setText("None"); 124 | 125 | jLabel16.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 126 | jLabel16.setText("None"); 127 | 128 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 129 | jPanel1.setLayout(jPanel1Layout); 130 | jPanel1Layout.setHorizontalGroup( 131 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 132 | .addGroup(jPanel1Layout.createSequentialGroup() 133 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 134 | .addGroup(jPanel1Layout.createSequentialGroup() 135 | .addGap(63, 63, 63) 136 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 137 | .addGroup(jPanel1Layout.createSequentialGroup() 138 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 139 | .addComponent(jLabel7) 140 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 141 | .addComponent(jLabel9) 142 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 143 | .addComponent(jLabel3) 144 | .addComponent(jLabel2) 145 | .addComponent(jLabel4) 146 | .addComponent(jLabel5) 147 | .addComponent(jLabel6)) 148 | .addGroup(jPanel1Layout.createSequentialGroup() 149 | .addGap(25, 25, 25) 150 | .addComponent(jLabel8)))) 151 | .addGap(61, 61, 61) 152 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 153 | .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 154 | .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 155 | .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE) 156 | .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 157 | .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 158 | .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 159 | .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE) 160 | .addComponent(jTextField6))) 161 | .addGroup(jPanel1Layout.createSequentialGroup() 162 | .addGap(47, 47, 47) 163 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)))) 164 | .addGroup(jPanel1Layout.createSequentialGroup() 165 | .addGap(109, 109, 109) 166 | .addComponent(jLabel1))) 167 | .addContainerGap(74, Short.MAX_VALUE)) 168 | ); 169 | jPanel1Layout.setVerticalGroup( 170 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 171 | .addGroup(jPanel1Layout.createSequentialGroup() 172 | .addGap(40, 40, 40) 173 | .addComponent(jLabel1) 174 | .addGap(39, 39, 39) 175 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 176 | .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 177 | .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 178 | .addGap(41, 41, 41) 179 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 180 | .addComponent(jLabel2) 181 | .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 182 | .addGap(33, 33, 33) 183 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 184 | .addComponent(jLabel3) 185 | .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 186 | .addGap(20, 20, 20) 187 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 188 | .addComponent(jLabel4) 189 | .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 190 | .addGap(18, 18, 18) 191 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 192 | .addComponent(jLabel5) 193 | .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 194 | .addGap(18, 18, 18) 195 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 196 | .addComponent(jLabel6) 197 | .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 198 | .addGap(18, 18, 18) 199 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 200 | .addComponent(jLabel8) 201 | .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 202 | .addGap(18, 18, 18) 203 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 204 | .addComponent(jLabel7) 205 | .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)) 206 | .addGap(18, 18, 18) 207 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 208 | .addGap(149, 149, 149)) 209 | ); 210 | 211 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 212 | getContentPane().setLayout(layout); 213 | layout.setHorizontalGroup( 214 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 215 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 216 | .addContainerGap() 217 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 218 | .addContainerGap()) 219 | ); 220 | layout.setVerticalGroup( 221 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 222 | .addGroup(layout.createSequentialGroup() 223 | .addContainerGap() 224 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 225 | ); 226 | 227 | pack(); 228 | }// //GEN-END:initComponents 229 | 230 | private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed 231 | // TODO add your handling code here: 232 | 233 | }//GEN-LAST:event_jTextField6ActionPerformed 234 | 235 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 236 | // TODO add your handling code here: 237 | Integer id = Integer.parseInt(jTextField6.getText()); 238 | try{ 239 | //step1 load the driver class 240 | Class.forName("oracle.jdbc.driver.OracleDriver"); 241 | 242 | //step2 create the connection object 243 | Config cfg = new Config(); 244 | String user = cfg.getProperty("ORACLE_USERNAME"); 245 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 246 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 247 | //step3 create the statement object 248 | 249 | String query = "delete from Students_Table where id = ?"; 250 | PreparedStatement stmt=con.prepareStatement(query); 251 | stmt.setInt(1, id); 252 | //step4 execute query 253 | 254 | // System.out.println(stmt.toString()); 255 | stmt.execute(); 256 | String str = "Record deleted"; 257 | System.out.println(str); 258 | JOptionPane.showMessageDialog(null,str); 259 | jLabel10.setText(null); 260 | jLabel11.setText(null); 261 | jLabel12.setText(null); 262 | jLabel13.setText(null); 263 | jLabel14.setText(null); 264 | jLabel15.setText(null); 265 | jLabel16.setText(null); 266 | 267 | con.close(); 268 | jTextField6.setText(null); 269 | }catch(Exception e){ System.out.println(e);} 270 | }//GEN-LAST:event_jButton1ActionPerformed 271 | 272 | private void jTextField6KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField6KeyReleased 273 | // TODO add your handling code here: 274 | try{ 275 | Integer id = Integer.parseInt(jTextField6.getText()); 276 | //step1 load the driver class 277 | 278 | Class.forName("oracle.jdbc.driver.OracleDriver"); 279 | //step2 create the connection object 280 | Config cfg = new Config(); 281 | String user = cfg.getProperty("ORACLE_USERNAME"); 282 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 283 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 284 | //step3 create the statement object 285 | String selectSQL = "SELECT id, first_name, last_name, dob, gender, CGPA, address, email FROM Students_Table WHERE id = ?"; 286 | 287 | PreparedStatement stmt=con.prepareStatement(selectSQL); 288 | stmt.setInt(1, id); 289 | //step4 execute query 290 | ResultSet rs = stmt.executeQuery(); 291 | if (!rs.isBeforeFirst()) { //if id is not present in database 292 | System.out.println("No data"); 293 | jLabel10.setText(null); 294 | jLabel11.setText(null); 295 | jLabel12.setText(null); 296 | jLabel13.setText(null); 297 | jLabel14.setText(null); 298 | jLabel15.setText(null); 299 | jLabel16.setText(null); 300 | 301 | } 302 | while (rs.next()) { 303 | String fname = rs.getString("first_name"); 304 | String lname = rs.getString("last_name"); 305 | Date dob = rs.getDate("dob"); 306 | String gender = rs.getString("gender"); 307 | Double cgpa = rs.getDouble("CGPA"); 308 | String address = rs.getString("address"); 309 | String email = rs.getString("email"); 310 | 311 | jLabel10.setText(fname); 312 | jLabel11.setText(lname); 313 | jLabel12.setText(String.valueOf(dob)); 314 | jLabel13.setText(gender); 315 | jLabel14.setText(String.valueOf(cgpa)); 316 | jLabel15.setText(address); 317 | jLabel16.setText(email); 318 | } 319 | 320 | // System.out.println(stmt.toString()); 321 | 322 | con.close(); 323 | 324 | }catch(Exception e){ 325 | jLabel10.setText("None"); 326 | jLabel11.setText("None"); 327 | jLabel12.setText("??-??-????"); 328 | jLabel13.setText("None"); 329 | jLabel14.setText("0.00"); 330 | jLabel15.setText("None"); 331 | jLabel16.setText("None"); 332 | System.out.println(e); 333 | } 334 | }//GEN-LAST:event_jTextField6KeyReleased 335 | 336 | /** 337 | * @param args the command line arguments 338 | */ 339 | public static void main(String args[]) { 340 | /* Set the Nimbus look and feel */ 341 | // 342 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 343 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 344 | */ 345 | try { 346 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 347 | if ("Nimbus".equals(info.getName())) { 348 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 349 | break; 350 | } 351 | } 352 | } catch (ClassNotFoundException ex) { 353 | java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 354 | } catch (InstantiationException ex) { 355 | java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 356 | } catch (IllegalAccessException ex) { 357 | java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 358 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 359 | java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 360 | } 361 | // 362 | 363 | /* Create and display the form */ 364 | java.awt.EventQueue.invokeLater(new Runnable() { 365 | public void run() { 366 | new DeleteStudentDetails().setVisible(true); 367 | } 368 | }); 369 | } 370 | 371 | // Variables declaration - do not modify//GEN-BEGIN:variables 372 | private javax.swing.JButton jButton1; 373 | private javax.swing.JLabel jLabel1; 374 | private javax.swing.JLabel jLabel10; 375 | private javax.swing.JLabel jLabel11; 376 | private javax.swing.JLabel jLabel12; 377 | private javax.swing.JLabel jLabel13; 378 | private javax.swing.JLabel jLabel14; 379 | private javax.swing.JLabel jLabel15; 380 | private javax.swing.JLabel jLabel16; 381 | private javax.swing.JLabel jLabel2; 382 | private javax.swing.JLabel jLabel3; 383 | private javax.swing.JLabel jLabel4; 384 | private javax.swing.JLabel jLabel5; 385 | private javax.swing.JLabel jLabel6; 386 | private javax.swing.JLabel jLabel7; 387 | private javax.swing.JLabel jLabel8; 388 | private javax.swing.JLabel jLabel9; 389 | private javax.swing.JPanel jPanel1; 390 | private javax.swing.JTextField jTextField6; 391 | // End of variables declaration//GEN-END:variables 392 | } 393 | -------------------------------------------------------------------------------- /src/dbtest/Home.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 |
291 |
292 | 293 | 294 | 295 | 296 | <Editor/> 297 | <Renderer/> 298 | </Column> 299 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 300 | <Title/> 301 | <Editor/> 302 | <Renderer/> 303 | </Column> 304 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 305 | <Title/> 306 | <Editor/> 307 | <Renderer/> 308 | </Column> 309 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 310 | <Title/> 311 | <Editor/> 312 | <Renderer/> 313 | </Column> 314 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 315 | <Title/> 316 | <Editor/> 317 | <Renderer/> 318 | </Column> 319 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 320 | <Title/> 321 | <Editor/> 322 | <Renderer/> 323 | </Column> 324 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 325 | <Title/> 326 | <Editor/> 327 | <Renderer/> 328 | </Column> 329 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 330 | <Title/> 331 | <Editor/> 332 | <Renderer/> 333 | </Column> 334 | </TableColumnModel> 335 | </Property> 336 | <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> 337 | <Color blue="ff" green="ff" red="ff" type="rgb"/> 338 | </Property> 339 | <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> 340 | <Dimension value="[10, 10]"/> 341 | </Property> 342 | <Property name="rowHeight" type="int" value="20"/> 343 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 344 | <TableHeader reorderingAllowed="false" resizingAllowed="true"/> 345 | </Property> 346 | </Properties> 347 | </Component> 348 | </SubComponents> 349 | </Container> 350 | </SubComponents> 351 | </Container> 352 | </SubComponents> 353 | </Container> 354 | <Component class="javax.swing.JLabel" name="jLabel2"> 355 | <Properties> 356 | <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> 357 | <Font name="Verdana" size="20" style="1"/> 358 | </Property> 359 | <Property name="text" type="java.lang.String" value="X"/> 360 | </Properties> 361 | <Events> 362 | <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jLabel2MousePressed"/> 363 | </Events> 364 | </Component> 365 | </SubComponents> 366 | </Form> 367 | -------------------------------------------------------------------------------- /src/dbtest/ModifyStudentDetails.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package dbtest; 7 | 8 | import static dbtest.AddNewStudent.isEmailValid; 9 | import java.sql.Connection; 10 | import java.sql.*; 11 | import java.sql.DriverManager; 12 | import java.sql.PreparedStatement; 13 | import java.sql.ResultSet; 14 | import javax.swing.JOptionPane; 15 | 16 | /** 17 | * 18 | * @author Issam 19 | */ 20 | public class ModifyStudentDetails extends javax.swing.JFrame { 21 | 22 | /** 23 | * Creates new form ModifyStudentDetails 24 | */ 25 | public ModifyStudentDetails() { 26 | initComponents(); 27 | } 28 | 29 | /** 30 | * This method is called from within the constructor to initialize the form. 31 | * WARNING: Do NOT modify this code. The content of this method is always 32 | * regenerated by the Form Editor. 33 | */ 34 | @SuppressWarnings("unchecked") 35 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 36 | private void initComponents() { 37 | 38 | jPanel1 = new javax.swing.JPanel(); 39 | jLabel1 = new javax.swing.JLabel(); 40 | jLabel2 = new javax.swing.JLabel(); 41 | jTextField1 = new javax.swing.JTextField(); 42 | jLabel3 = new javax.swing.JLabel(); 43 | jLabel4 = new javax.swing.JLabel(); 44 | jLabel5 = new javax.swing.JLabel(); 45 | jLabel6 = new javax.swing.JLabel(); 46 | jLabel7 = new javax.swing.JLabel(); 47 | jLabel8 = new javax.swing.JLabel(); 48 | jTextField2 = new javax.swing.JTextField(); 49 | jComboBox1 = new javax.swing.JComboBox<>(); 50 | jTextField3 = new javax.swing.JTextField(); 51 | jTextField4 = new javax.swing.JTextField(); 52 | jTextField5 = new javax.swing.JTextField(); 53 | jDateChooser1 = new com.toedter.calendar.JDateChooser(); 54 | jButton1 = new javax.swing.JButton(); 55 | jLabel9 = new javax.swing.JLabel(); 56 | jTextField6 = new javax.swing.JTextField(); 57 | 58 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); 59 | setPreferredSize(new java.awt.Dimension(502, 479)); 60 | 61 | jLabel1.setFont(new java.awt.Font("Comfortaa", 1, 20)); // NOI18N 62 | jLabel1.setText("Update Student Details"); 63 | 64 | jLabel2.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 65 | jLabel2.setText("First Name"); 66 | 67 | jTextField1.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 68 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 69 | public void actionPerformed(java.awt.event.ActionEvent evt) { 70 | jTextField1ActionPerformed(evt); 71 | } 72 | }); 73 | 74 | jLabel3.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 75 | jLabel3.setText("Last Name"); 76 | 77 | jLabel4.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 78 | jLabel4.setText("DOB"); 79 | 80 | jLabel5.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 81 | jLabel5.setText("Gender"); 82 | 83 | jLabel6.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 84 | jLabel6.setText("CGPA"); 85 | 86 | jLabel7.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 87 | jLabel7.setText("Email"); 88 | 89 | jLabel8.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 90 | jLabel8.setText("Address"); 91 | 92 | jTextField2.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 93 | jTextField2.addActionListener(new java.awt.event.ActionListener() { 94 | public void actionPerformed(java.awt.event.ActionEvent evt) { 95 | jTextField2ActionPerformed(evt); 96 | } 97 | }); 98 | 99 | jComboBox1.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 100 | jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Male", "Female" })); 101 | jComboBox1.addActionListener(new java.awt.event.ActionListener() { 102 | public void actionPerformed(java.awt.event.ActionEvent evt) { 103 | jComboBox1ActionPerformed(evt); 104 | } 105 | }); 106 | 107 | jTextField3.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 108 | jTextField3.addActionListener(new java.awt.event.ActionListener() { 109 | public void actionPerformed(java.awt.event.ActionEvent evt) { 110 | jTextField3ActionPerformed(evt); 111 | } 112 | }); 113 | 114 | jTextField4.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 115 | 116 | jTextField5.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 117 | 118 | jButton1.setFont(new java.awt.Font("Comfortaa", 0, 14)); // NOI18N 119 | jButton1.setText("Update Student Record"); 120 | jButton1.addActionListener(new java.awt.event.ActionListener() { 121 | public void actionPerformed(java.awt.event.ActionEvent evt) { 122 | jButton1ActionPerformed(evt); 123 | } 124 | }); 125 | 126 | jLabel9.setFont(new java.awt.Font("Comfortaa", 1, 14)); // NOI18N 127 | jLabel9.setText("ID"); 128 | 129 | jTextField6.setFont(new java.awt.Font("Comfortaa", 0, 12)); // NOI18N 130 | jTextField6.addActionListener(new java.awt.event.ActionListener() { 131 | public void actionPerformed(java.awt.event.ActionEvent evt) { 132 | jTextField6ActionPerformed(evt); 133 | } 134 | }); 135 | jTextField6.addKeyListener(new java.awt.event.KeyAdapter() { 136 | public void keyPressed(java.awt.event.KeyEvent evt) { 137 | jTextField6KeyPressed(evt); 138 | } 139 | public void keyReleased(java.awt.event.KeyEvent evt) { 140 | jTextField6KeyReleased(evt); 141 | } 142 | public void keyTyped(java.awt.event.KeyEvent evt) { 143 | jTextField6KeyTyped(evt); 144 | } 145 | }); 146 | 147 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 148 | jPanel1.setLayout(jPanel1Layout); 149 | jPanel1Layout.setHorizontalGroup( 150 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 151 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 152 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 153 | .addComponent(jLabel1) 154 | .addGap(108, 108, 108)) 155 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 156 | .addGap(106, 106, 106) 157 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 158 | .addGroup(jPanel1Layout.createSequentialGroup() 159 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 160 | .addComponent(jLabel9) 161 | .addComponent(jLabel3) 162 | .addComponent(jLabel2) 163 | .addComponent(jLabel4) 164 | .addComponent(jLabel5) 165 | .addComponent(jLabel6) 166 | .addComponent(jLabel8) 167 | .addComponent(jLabel7)) 168 | .addGap(85, 85, 85) 169 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 170 | .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING) 171 | .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 172 | .addComponent(jDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 173 | .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE) 174 | .addComponent(jTextField3) 175 | .addComponent(jTextField2) 176 | .addComponent(jTextField5) 177 | .addComponent(jTextField6)) 178 | .addGap(100, 100, 100)) 179 | .addGroup(jPanel1Layout.createSequentialGroup() 180 | .addGap(2, 2, 2) 181 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE) 182 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) 183 | ); 184 | jPanel1Layout.setVerticalGroup( 185 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 186 | .addGroup(jPanel1Layout.createSequentialGroup() 187 | .addGap(42, 42, 42) 188 | .addComponent(jLabel1) 189 | .addGap(18, 18, 18) 190 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 191 | .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 192 | .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 193 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE) 194 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 195 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 196 | .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 197 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 198 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 199 | .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 200 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 201 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 202 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 203 | .addComponent(jLabel4) 204 | .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 205 | .addGap(29, 29, 29) 206 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 207 | .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 208 | .addGroup(jPanel1Layout.createSequentialGroup() 209 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 210 | .addComponent(jLabel5) 211 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 212 | .addGap(30, 30, 30) 213 | .addComponent(jLabel6))) 214 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 215 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 216 | .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 217 | .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 218 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 219 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 220 | .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) 221 | .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 222 | .addGap(30, 30, 30) 223 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 224 | .addContainerGap(23, Short.MAX_VALUE)) 225 | ); 226 | 227 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 228 | getContentPane().setLayout(layout); 229 | layout.setHorizontalGroup( 230 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 231 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 232 | .addContainerGap() 233 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 234 | .addContainerGap()) 235 | ); 236 | layout.setVerticalGroup( 237 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 238 | .addGroup(layout.createSequentialGroup() 239 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 240 | .addContainerGap(52, Short.MAX_VALUE)) 241 | ); 242 | 243 | pack(); 244 | }// </editor-fold>//GEN-END:initComponents 245 | 246 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed 247 | // TODO add your handling code here: 248 | }//GEN-LAST:event_jTextField1ActionPerformed 249 | 250 | private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed 251 | // TODO add your handling code here: 252 | }//GEN-LAST:event_jTextField2ActionPerformed 253 | 254 | private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed 255 | // TODO add your handling code here: 256 | }//GEN-LAST:event_jComboBox1ActionPerformed 257 | 258 | private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed 259 | // TODO add your handling code here: 260 | }//GEN-LAST:event_jTextField3ActionPerformed 261 | 262 | private void jTextField6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField6ActionPerformed 263 | // TODO add your handling code here: 264 | 265 | 266 | }//GEN-LAST:event_jTextField6ActionPerformed 267 | 268 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 269 | // TODO add your handling code here: 270 | Integer id = Integer.parseInt(jTextField6.getText()); 271 | String fname = jTextField1.getText(); 272 | String lname = jTextField2.getText(); 273 | Date dob = new java.sql.Date(jDateChooser1.getDate().getTime()); 274 | String gender = jComboBox1.getSelectedItem().toString(); 275 | Double cgpa = Double.parseDouble(jTextField3.getText()); 276 | String address = jTextField4.getText(); 277 | String email = jTextField5.getText(); 278 | try{ 279 | if(!isEmailValid(email)){ 280 | throw new Exception("Invalid Email Address"); 281 | } 282 | if(cgpa<0 || cgpa>10){ 283 | throw new Exception("Invalid CGPA"); 284 | } 285 | long timeNow = new java.util.Date().getTime(); 286 | if(dob.getTime() > timeNow){ 287 | throw new Exception("Invalid Date of Birth"); 288 | } 289 | 290 | if(isEmailValid(email) && (cgpa >= 0 && cgpa <= 10) && (dob.getTime() < timeNow)){ 291 | 292 | //step1 load the driver class 293 | Class.forName("oracle.jdbc.driver.OracleDriver"); 294 | 295 | //step2 create the connection object 296 | Config cfg = new Config(); 297 | String user = cfg.getProperty("ORACLE_USERNAME"); 298 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 299 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 300 | //step3 create the statement object 301 | PreparedStatement stmt=con.prepareStatement("update Students_Table set first_name=?, last_name=?,dob=?,gender=?,CGPA=?,address=?,email=? where id=?"); 302 | //step4 execute query 303 | 304 | stmt.setInt(8, id); 305 | stmt.setString(1,fname); 306 | stmt.setString(2,lname); 307 | stmt.setDate(3,new java.sql.Date(dob.getTime())); 308 | stmt.setString(4,gender); 309 | stmt.setDouble(5,cgpa); 310 | stmt.setString(6,address); 311 | stmt.setString(7, email); 312 | 313 | 314 | // System.out.println(stmt.toString()); 315 | int i = stmt.executeUpdate(); 316 | String str = i+" records updated"; 317 | System.out.println(str); 318 | JOptionPane.showMessageDialog(null,str); 319 | con.close(); 320 | 321 | jTextField1.setText(null); 322 | jTextField2.setText(null); 323 | jDateChooser1.setDate(null); 324 | jComboBox1.setSelectedItem(null); 325 | jTextField3.setText(null); 326 | jTextField4.setText(null); 327 | jTextField5.setText(null); 328 | jTextField6.setText(null); 329 | } 330 | }catch(Exception e){ System.out.println(e);JOptionPane.showMessageDialog(null,e.toString());} 331 | 332 | }//GEN-LAST:event_jButton1ActionPerformed 333 | 334 | private void jTextField6KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField6KeyPressed 335 | 336 | }//GEN-LAST:event_jTextField6KeyPressed 337 | 338 | private void jTextField6KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField6KeyTyped 339 | // TODO add your handling code here: 340 | // TODO add your handling code here: 341 | 342 | 343 | }//GEN-LAST:event_jTextField6KeyTyped 344 | 345 | private void jTextField6KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField6KeyReleased 346 | // TODO add your handling code here: 347 | try{ 348 | Integer id = Integer.parseInt(jTextField6.getText()); 349 | //step1 load the driver class 350 | 351 | Class.forName("oracle.jdbc.driver.OracleDriver"); 352 | //step2 create the connection object 353 | Config cfg = new Config(); 354 | String user = cfg.getProperty("ORACLE_USERNAME"); 355 | String pass = cfg.getProperty("ORACLE_PASSWORD"); 356 | Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",user,pass); 357 | //step3 create the statement object 358 | String selectSQL = "SELECT id, first_name, last_name, dob, gender, CGPA, address, email FROM Students_Table WHERE id = ?"; 359 | 360 | PreparedStatement stmt=con.prepareStatement(selectSQL); 361 | stmt.setInt(1, id); 362 | //step4 execute query 363 | ResultSet rs = stmt.executeQuery(); 364 | if (!rs.isBeforeFirst()) { //if id is not presentin database 365 | System.out.println("No data"); 366 | jTextField1.setText(null); 367 | jTextField2.setText(null); 368 | jDateChooser1.setDate(null); 369 | jComboBox1.setSelectedItem(null); 370 | jTextField3.setText(null); 371 | jTextField4.setText(null); 372 | jTextField5.setText(null); 373 | 374 | } 375 | while (rs.next()) { 376 | String fname = rs.getString("first_name"); 377 | String lname = rs.getString("last_name"); 378 | Date dob = rs.getDate("dob"); 379 | String gender = rs.getString("gender"); 380 | Double cgpa = rs.getDouble("CGPA"); 381 | String address = rs.getString("address"); 382 | String email = rs.getString("email"); 383 | 384 | jTextField1.setText(fname); 385 | jTextField2.setText(lname); 386 | jDateChooser1.setDate(dob); 387 | jComboBox1.setSelectedItem(gender); 388 | jTextField3.setText(String.valueOf(cgpa)); 389 | jTextField4.setText(address); 390 | jTextField5.setText(email); 391 | } 392 | 393 | // System.out.println(stmt.toString()); 394 | 395 | con.close(); 396 | 397 | }catch(Exception e){ 398 | System.out.println(e); 399 | jTextField1.setText(null); 400 | jTextField2.setText(null); 401 | jDateChooser1.setDate(null); 402 | jComboBox1.setSelectedItem(null); 403 | jTextField3.setText(null); 404 | jTextField4.setText(null); 405 | jTextField5.setText(null); 406 | } 407 | }//GEN-LAST:event_jTextField6KeyReleased 408 | 409 | /** 410 | * @param args the command line arguments 411 | */ 412 | public static void main(String args[]) { 413 | /* Set the Nimbus look and feel */ 414 | //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> 415 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 416 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 417 | */ 418 | try { 419 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 420 | if ("Nimbus".equals(info.getName())) { 421 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 422 | break; 423 | } 424 | } 425 | } catch (ClassNotFoundException ex) { 426 | java.util.logging.Logger.getLogger(ModifyStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 427 | } catch (InstantiationException ex) { 428 | java.util.logging.Logger.getLogger(ModifyStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 429 | } catch (IllegalAccessException ex) { 430 | java.util.logging.Logger.getLogger(ModifyStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 431 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 432 | java.util.logging.Logger.getLogger(ModifyStudentDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 433 | } 434 | //</editor-fold> 435 | 436 | /* Create and display the form */ 437 | java.awt.EventQueue.invokeLater(new Runnable() { 438 | public void run() { 439 | new ModifyStudentDetails().setVisible(true); 440 | } 441 | }); 442 | } 443 | 444 | // Variables declaration - do not modify//GEN-BEGIN:variables 445 | private javax.swing.JButton jButton1; 446 | private javax.swing.JComboBox<String> jComboBox1; 447 | private com.toedter.calendar.JDateChooser jDateChooser1; 448 | private javax.swing.JLabel jLabel1; 449 | private javax.swing.JLabel jLabel2; 450 | private javax.swing.JLabel jLabel3; 451 | private javax.swing.JLabel jLabel4; 452 | private javax.swing.JLabel jLabel5; 453 | private javax.swing.JLabel jLabel6; 454 | private javax.swing.JLabel jLabel7; 455 | private javax.swing.JLabel jLabel8; 456 | private javax.swing.JLabel jLabel9; 457 | private javax.swing.JPanel jPanel1; 458 | private javax.swing.JTextField jTextField1; 459 | private javax.swing.JTextField jTextField2; 460 | private javax.swing.JTextField jTextField3; 461 | private javax.swing.JTextField jTextField4; 462 | private javax.swing.JTextField jTextField5; 463 | private javax.swing.JTextField jTextField6; 464 | // End of variables declaration//GEN-END:variables 465 | } 466 | --------------------------------------------------------------------------------