Blog Archives
1 23 24 25 26 27 28

Spring IO tutorial in 6 steps

Spring IO Platform is all about “list of dependencies and their versions that work well together”. It is implemented as a Maven POM file via Maven Bill-of-Materials dependency that you can import into your projects to set the versions for dependencies. You can go to “ … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Spring loading property files & properties

conf/db.properties

# jdbc.X
jdbc.driverClassName=org.hsqldb.jdbcDriver
jdbc.url=jdbc:hsqldb:hsql://localhost/mytestdb
jdbc.user=SA
jdbc.pass=
# hibernate.X
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=

#1. Register a Properties File in Application Context XML

The “<property-placeholder>” tag.

OR

#2.

Read more ›



Spring, JavaConfig (@Configuration), and TransactionManager

This extedns configuring JDBC and JPA to configure the TransactionManager.

Example #1 Wiring JDBC Transaction Manager

Note: @EnableTransactionManagement annotation

If you want to create a mock transaction manager, then you can do

Also,

Read more ›



Spring, JavaConfig (i.e @Configuration) & JDBC by example

Example #1 Wiring JDBC Datasource

application.yml where the datasource properties are read.

Example #2 Wiring JDBC Datasource with JNDI

Example #3 Wiring JDBC Embedded Datasource for integration testing

Example #4 Wiring up the JdbcTemplate by passing in the datasource

Example #5 Wiring up a DAO...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Spring, JavaConfig (i.e @Configuration) & JMS by example

Step 1: Define the messaging system connectivity, destination (e.g. topic or queue) and message selector properties via a YAML or .properties file. Here is an example of application.yml file.

Step 2: MQTopicConnectionFactory The Java based Spring configuration defining the connection factory. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Stack from scratch Java example

Q. If Java did not have a Stack implementation, how would you go about implementing your own? A. Determine the backing data structure (e.g. array, linked list, etc). Determine the methods that need to be implemented like pop( ), push( ), … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Swap 2 values & bubble sort in Java

Q1. Can you write an algorithm to swap two values? A1.

Swapping without a temp variable

Note: also try with * and \ Using bitwise “xor”

Q2. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Swapping, partitioning, and sorting algorithms in Java

Q1. Can you write an algorithm in Java to swap two variables? A1.

Q2. Can you write an algorithm to bubble sort the following array { 30, 12, 18, 0, -5, 72, 424 }?? … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Top 10 causes of performance issues in Java

Cause #1: The JVM spends more time performing garbage collection due to improper Garbage Collection (GC) configuration. E.g. Young generation being too small. Heap size is too small (use -Xmx). The application footprint is larger than the allocated heap size. … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Two Pointers: Partitioning around a pivotal number

Q. How will you partition the following numbers 7 3 6 8 2 9 5 4 around the pivotal number of 5 so that the lower values are in front of it and higher values are behind it? The pointers are shown with: “^” … Read more ›...

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only. Register 50+ Free Java FAQs 50+ Free Big Data FAQs
Already a member? Log in here


Unit Test Hibernate – DAO Layer with JPA, Spring & HSQLDB

This post extends the previous one on “Unit Test Hibernate – DAO Layer with Spring & HSQLDB“. The changes are

1. Add “persistence-jpa.xml” to src/main/resources.

2. Modify the “entityManagerFactory()” method in the “SimpleConfig.java”.

Read more ›



Unit Test Hibernate – DAO Layer with Spring & HSQLDB

Step 1: The pom.xml file with test jars, Spring jars, and hibernate jars

Step 2: The HSQL DB schema and data scripts in the src/test/resources folder.

sql/schema.sql

sql/data.sql

Step 3: The Spring configuration for the unit tests in the src/test/java folder.

Read more ›



Unit Testing Data Access Logic in Java

Most interviewers like Java candidates those who are passionate and experienced about writing unit tests. Any non trivial Java application will be making calls to database tables. So, here are a few questions and answers testing your ability to write unit tests to test data access layer.

Q1.

Read more ›



1 23 24 25 26 27 28

300+ Java Interview FAQs

Tutorials on Java & Big Data