16 |
17 | |Project Codename|Bali|
18 | |--|--|
19 | | Blog Post URL | http://www.techilashots.com/2009/01/spring-hibernate-ehcache-recipe.html |
20 | |Blog Short URL |https://goo.gl/sKX2SV |
21 | |Package Prefix|me.sumithpuri.github.bali |
22 | |GitHub URL|https://github.com/sumithpuri/skp-code-marathon-bali |
23 | |Contact E-Mail |code@sumithpuri.xyz|
24 | |Contact Number|+91 9591497974 (WhatsApp, Viber, Telegram)|
25 | |Historical|✅ Started this Movement of 1000s of Lines of Java/EE* Code to GitHub
✅ Was a Senior Software Architect (Java/EE) in Manila*, 2018 (At Start)
✅ Named this Initial Code Journey as [ Manila Code Marathon - 2018 ]
✅ Code Is Non-Proprietary / Non-Copyright from my Work Experience.
✅ Was Back to Bangalore, Named as [ Bangalore Code Nights - 2019. ]
✅ Added More Code under [ -20 Days of Code in Benglauru- ] in 2020
✅ Celebration of Java/Java EE Code as Java Turned 25 in the Year 2020! |
26 |
27 |
28 |
29 |
30 |
33 |
34 |
35 |  |
36 |
37 | ❤️ Ex-Yahoo, Symantec, Huawei, Oracle*, OpenText*, Finastra*, Atos* 🧡 Xth, XIIth (Computer Science) - Naval Public School, Kochi, India 💛 Bachelor of Engineering (Computer Science)* - SRSIT, Bangalore 💜 Executive Program ( Data Mining and Analytics ) - [IIT, Roorkee] 💚 Executive Certificate Program (Entrepreneurship) - IIM, Kashipur
💙 Proficience (Cryptography & Network Security) - IISc, Bangalore 🤎 Proficience (Innovative Product Design & Dev.) - IISc, Bangalore 🖤 Proficience (Artficial Intelligence/Intelli Agents) - IISc, Bangalore
💎 Sun Certified Java Programmer 1.4 (Core Java) 💎 Sun Certified Java Programmer 5.0 (Core Java) 💎 Sun Certified Business Component Developer 1.3 (EJB/J2EE) 💎 Sun Certified Business Component Developer 5.0 (EJB/J2EE) 💎 Brainbench Spring 2.x Certification*, ( J2EE/Spring ) 💎 Brainbench Hibernate 3.x Certification* (Hibernate) 💎 Brainbench Java EE 6.x Certification*, ( J2EE ) 💎 Quest C Lang. Certification (C Programming) 💎 Quest C++ Certification (C++ Programming) 💎 Quest Data Structures Certification ( C/C++ )
38 | 🏁 Highest IQ (147) ~ Among Entire Secondary School Batch ~ (Xth) 🏁 MVIT Inter-Collegiate C Programming Contest (Finalist, Top 8) 🏁 SJCIT Inter-Collegiate Web Design (Runners-Up) 🏁 Google India Code Jam 2005 (#376/14,000) - India + SE Asia 🏁 Microsoft Bizspark Startup 2011-'12 (Shortlisted/Recognized) 🏁 Societe Generale Brainwaves Hackathon 2015 (Corp Finalist, AI) 🏁 Mphasis Internal Hackathon Challenge, Season-07 (#07/106)* 🏁 Techgig Code Gladiators 2015 (Open, Top 500) 🏁 Accenture in India YouTube Contest 2015 (BigData, Winner) 🏁 Xebia-Microsoft-GitHub Blogathon 2022 (Microservices, Winner)
🏆 Senior Member, ACM (Elevated) and Senior Member, IEEE (Elevated) 🏆 Author/Blogger, Technology Advice (Developer.com and jGuru) 🏆 DZone Most Valuable Blogger and DZone Core (Elevated)** 🏆 Author and Blogger, Friends of Open JDK Community (Foojay.IO) 🏆 Blogger, Java Code Geeks Program (Shortlisted/Recognized) 🏆 Paid Blogger, Developer.com and jGuru; Blogger, HackerNoon; 🎯 19y Across Associate/Engineer (2003) to Java Practice Leader (2024) |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
🔴 ALL COPYRIGHTS FOR THE ABOVE PUBLICLY AVAILABLE IMAGE OR PARTS OF THE IMAGE ARE WITH THEIR RESPECTIVE OWNERS, SOURCED/USED FROM GOOGLE SEARCH
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/main/java/me/sumithpuri/github/bali/data/loader/BaliDataLoader.java:
--------------------------------------------------------------------------------
1 | package me.sumithpuri.github.bali.data.loader;
2 |
3 | import java.sql.Connection;
4 | import java.sql.DriverManager;
5 | import java.sql.PreparedStatement;
6 | import java.sql.SQLException;
7 | import java.sql.Statement;
8 |
9 | /**
10 | * MIT License
11 | *
12 | * Copyright (c) 2018-19, Sumith Kumar Puri
13 |
14 | * GitHub URL https://github.com/sumithpuri
15 | * Blog Post URL http://www.techilashots.com/2009/01/spring-hibernate-ehcache-recipe.html
16 | * Blog Short URL https://goo.gl/sKX2SV
17 | * Package Prefix me.sumithpuri.github.bali
18 | * Project Codename bali
19 | * Contact E-Mail code@sumithpuri.me
20 | * Contact WhatsApp +91 9591497974
21 | *
22 | *
23 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
24 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
25 | * rights to use, copy, modify, merge, publish, distribute, sub-license and/or sell copies of the Software and to permit
26 | * persons to whom the Software is furnished to do so, subject to the following conditions:
27 | *
28 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
29 | * Software.
30 | *
31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
32 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
33 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
34 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 | */
36 | public class BaliDataLoader {
37 |
38 | private Connection connection = null;
39 |
40 | public BaliDataLoader() {
41 |
42 | try {
43 |
44 | Class.forName("com.mysql.jdbc.Driver");
45 | } catch (Exception e) {
46 |
47 | System.out.println("Exception while Loading mySQL JDBC Driver!");
48 | }
49 | }
50 |
51 | public void loadConnection(String userName, String passWord, String databaseName, String serverName,
52 | Integer portNumber) {
53 |
54 | String connectionUrl = "jdbc:mysql://" + serverName + ":" + portNumber + "/" + databaseName;
55 |
56 | try {
57 |
58 | connection = DriverManager.getConnection(connectionUrl, userName, passWord);
59 | } catch (Exception e) {
60 |
61 | System.out.println("Exception while creating a JDBC Connection!");
62 | }
63 | }
64 |
65 | public static void main(String args[]) {
66 |
67 | BaliDataLoader dataLoader = new BaliDataLoader();
68 | dataLoader.loadConnection("root", "Collabera@2018", "data_explosion", "localhost", 3306);
69 |
70 | try {
71 |
72 | dataLoader.refreshDatabase();
73 | dataLoader.loadDoctorData();
74 | } catch (Exception e) {
75 | System.out.println("Error in executing SQL: " + e.getMessage());
76 | }
77 | }
78 |
79 | public void refreshDatabase() throws SQLException {
80 |
81 | Statement statement = connection.createStatement();
82 | statement.execute("DELETE FROM DOCTOR_TABLE");
83 | statement.close();
84 | }
85 |
86 | public void loadDoctorData() throws SQLException {
87 |
88 | String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
89 | String select[] = new String[] { "SCURVY", "BERIBERI", "FOOTMOUTH", "CHOLERA", "TYPHOID", "FLU" };
90 | String insertStatement = "INSERT INTO DOCTOR_TABLE VALUES(?,?,?)";
91 | PreparedStatement statement = connection.prepareStatement(insertStatement);
92 | String doctorName = null;
93 | String speciality = null;
94 |
95 | for (int i = 1; i < 5000; i++) {
96 |
97 | int alphabetFr = (int) (Math.random() * alphabet.length());
98 | alphabetFr = (alphabetFr == 0) ? 1 : alphabetFr;
99 | int remAlphabet = alphabet.length() - alphabetFr;
100 | int alphabetTo = (int) (Math.random() * remAlphabet);
101 | int specialInd = (int) (Math.random() * select.length);
102 | doctorName = alphabet.substring(alphabetFr, alphabetFr + alphabetTo);
103 | speciality = select[specialInd];
104 |
105 | System.out.println("DOCTOR_TABLE: " + i + " " + doctorName + " " + speciality);
106 |
107 | statement.setInt(1, i);
108 | statement.setString(2, doctorName);
109 | statement.setString(3, speciality);
110 |
111 | statement.execute();
112 | }
113 | }
114 |
115 | public Connection getConnection() {
116 | return connection;
117 | }
118 |
119 | public void setConnection(Connection connection) {
120 | this.connection = connection;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/main/java/me/sumithpuri/github/bali/app/Bali.java:
--------------------------------------------------------------------------------
1 | package me.sumithpuri.github.bali.app;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.context.ApplicationContext;
6 | import org.springframework.context.support.ClassPathXmlApplicationContext;
7 |
8 | import me.sumithpuri.github.bali.spring.orm.sample.Doctor;
9 | import me.sumithpuri.github.bali.spring.orm.sample.HibernateDoctorDao;
10 |
11 | /**
12 | * MIT License
13 | *
14 | * Copyright (c) 2018-19, Sumith Kumar Puri
15 |
16 | * GitHub URL https://github.com/sumithpuri
17 | * Blog Post URL http://www.techilashots.com/2009/01/spring-hibernate-ehcache-recipe.html
18 | * Blog Short URL https://goo.gl/sKX2SV
19 | * Package Prefix me.sumithpuri.github.bali
20 | * Project Codename bali
21 | * Contact E-Mail code@sumithpuri.me
22 | * Contact WhatsApp +91 9591497974
23 | *
24 | *
25 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
26 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
27 | * rights to use, copy, modify, merge, publish, distribute, sub-license and/or sell copies of the Software and to permit
28 | * persons to whom the Software is furnished to do so, subject to the following conditions:
29 | *
30 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
31 | * Software.
32 | *
33 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
34 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
35 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
36 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 | */
38 | public class Bali {
39 |
40 | private static boolean isDatabaseSetup = false;
41 |
42 | public static void main(String args[]) {
43 |
44 | // SherlockEvent DataM1 = new SherlockEvent();
45 | System.out.println("Copyright (c) 2018-19, Sumith Kumar Puri");
46 | System.out.println();
47 | System.out.println("Project Codename Bali");
48 | System.out.println("Project Description Spring, Hibernate, EhCache (Performance) Demo Code");
49 | System.out.println("Technical Blog http://www.techilashots.com");
50 | System.out.println("Technical Blog Post https://goo.gl/sKX2SV");
51 | System.out.println("[Developer Notes] [01] Use Java Version 9.0+ Compiler");
52 | System.out.println();
53 | System.out.println("Spring, Hibernate, EhCache (2nd Level Cache) Demo n Performance");
54 | System.out.println("################################################################");
55 |
56 | if(isDatabaseSetup) {
57 |
58 | ApplicationContext context = new ClassPathXmlApplicationContext("orm-sample.xml");
59 |
60 | HibernateDoctorDao doctorDao = (HibernateDoctorDao) context.getBean("doctorDao");
61 | Doctor doctor = doctorDao.getDoctorById(2);
62 |
63 | System.out.println("PERFORMANCE COMPARISON (in seconds)");
64 | System.out.println("==================================");
65 |
66 | long startTime = System.currentTimeMillis();
67 | List
doctors = doctorDao.getAllDoctorsOnSecondLevelCache();
68 | long finishTime = System.currentTimeMillis();
69 |
70 | System.out.println("QUERY FETCH TIME (INITIAL): " + (finishTime-startTime)/1000.0);
71 |
72 | startTime = System.currentTimeMillis();
73 | doctors = doctorDao.getAllDoctorsOnHibernateOnly();
74 | finishTime = System.currentTimeMillis();
75 |
76 | System.out.println("QUERY FETCH TIME (HIBERNATE CACHE): " + (finishTime-startTime)/1000.0);
77 |
78 | startTime = System.currentTimeMillis();
79 | doctors = doctorDao.getAllDoctorsOnSecondLevelCache();
80 | finishTime = System.currentTimeMillis();
81 |
82 | System.out.println("QUERY FETCH TIME (2ND LEVEL CACHE): " + (finishTime-startTime)/1000.0);
83 |
84 | } else {
85 |
86 | System.out.println("000. You may choose to Import the Project in Eclipse / Other IDE");
87 | System.out.println("000. Make Sure that Dependencies & Resources are in ClassPath");
88 | System.out.println("01a. Install MySQL Community Server Version 5.7.0+ [Developer Default]");
89 | System.out.println("01b. Make Sure that Schema is Created using [doctor.sql]");
90 | System.out.println("000. You may use MySQL Workbench or Eclipse to execute [doctor.sql]");
91 | System.out.println("02a. Make Sure you add the Password in the [orm-sample.xml]");
92 | System.out.println("000. *Update the [isDatabaseSetup] attribute to [true] in [Bali]*");
93 | System.out.println("02b. Next, Run [BaliDataLoader] from Eclipse/Console (With Classpath Set)");
94 | System.out.println("003. [Bali] Spring-Hibernate-EhCache Demo should show the Performance Data");
95 | System.out.println();
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 |
6 | me.sumithpuri.github
7 | skp-mini-marathon-bali
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 |
12 | Bali : Brainbench Spring 2.5 Certification
13 | http://maven.apache.org
14 |
15 |
16 | UTF-8
17 | 9
18 | 9
19 | false
20 |
21 |
22 |
23 |
24 | junit
25 | junit
26 | 3.8.1
27 | test
28 |
29 |
30 |
31 | org.springframework
32 | spring
33 | 2.5.5
34 |
35 |
36 | org.springframework
37 | spring-aspects
38 | 2.5.5
39 |
40 |
41 | org.hibernate
42 | hibernate
43 | 3.1.3
44 |
45 |
46 | ehcache
47 | ehcache
48 |
49 |
50 |
51 |
52 | javax.transaction
53 | jta
54 | 1.1
55 |
56 |
57 | commons-dbcp
58 | commons-dbcp
59 | 1.2.2
60 |
61 |
62 | mysql
63 | mysql-connector-java
64 | 5.0.8
65 |
66 |
67 | net.sf.ehcache
68 | ehcache
69 | 1.3.0
70 |
71 |
72 | org.springmodules
73 | spring-modules-cache
74 | 0.8a
75 |
76 |
77 |
78 |
79 | org.springframework
80 | spring
81 |
82 |
83 | gigaspaces
84 | gigaspaces-ce
85 |
86 |
87 | jini
88 | jsk-lib
89 |
90 |
91 | jini
92 | jsk-platform
93 |
94 |
95 | jini
96 | mahalo
97 |
98 |
99 | jini
100 | reggie
101 |
102 |
103 | jini
104 | start
105 |
106 |
107 | jini
108 | boot
109 |
110 |
111 | jini
112 | webster
113 |
114 |
115 | commons-attributes
116 | commons-attributes-api
117 |
118 |
119 | commons-attributes
120 | commons-attributes-compiler
121 |
122 |
123 | cglib
124 | cglib-nodep
125 |
126 |
127 | jboss
128 | javassist
129 |
130 |
131 | jboss
132 | jboss-cache
133 |
134 |
135 | jboss
136 | jboss-common
137 |
138 |
139 | jboss
140 | jboss-jmx
141 |
142 |
143 | jboss
144 | jboss-minimal
145 |
146 |
147 | jboss
148 | jboss-system
149 |
150 |
151 | jcs
152 | jcs
153 |
154 |
155 | jgroups
156 | jgroups-all
157 |
158 |
159 | geronimo-spec
160 | geronimo-spec-jta
161 |
162 |
163 | xpp3
164 | xpp3_min
165 |
166 |
167 | xjavadoc
168 | xjavadoc
169 |
170 |
171 | opensymphony
172 | oscache
173 |
174 |
175 | ehcache
176 | ehcache
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 | org.apache.maven.plugins
185 | maven-compiler-plugin
186 | 3.6.1
187 |
188 |
189 | org.codehaus.mojo
190 | exec-maven-plugin
191 | 1.6.0
192 |
193 |
194 | test
195 |
196 | java
197 |
198 |
199 | me.sumithpuri.github.bali.app.Bali
200 | true
201 |
202 |
203 |
204 |
205 |
206 |
207 | Brainbench Spring 2.5 Certification (+ Spring In Action Samples)
208 |
209 |
--------------------------------------------------------------------------------