Posted In: Server, Tomcat

Tomcat 9 – How to correct java.sql.SQLException: No suitable driver found

Case 1 – Using Tomcat connection pool Developer is using to create JNDI. Then please verify TOMCAT/lib has JDBC drivers available. Oracle – ojdbc6.jar MySQL – mysql-connector-java-6.0.5.jar HSQLDB – hsqldb-1.8.0.7.jar PostgreSQL – PostgreSQL JDBC 4.1 Driver, 42.1.4.jre7 Case 2 – Using JDBC driver manager to create connection Either put driver jar in WEB-INF/lib of your […]

Read More

by , on August 26th, 2017

Posted In: Server, Tomcat

How to set the context path of a web application in Tomcat 9

How to set the context path to “/” or root of a web application in Tomcat 9 Deploying my application at the root in Tomcat 1. Setting context path using Eclipse   Set context path in server web module   Set context path in Web project settings   2. Setting context path “/” directly on […]

Read More

by , on August 26th, 2017

Posted In: Apache, Server, Tomcat, Tomcat

How to save uploaded files in a enterprise application

Before writing about how to upload file developer needs to consider how to choose location to upload the file.   1. Not clustered environment – Basic file system Case 1 – Uploading files to Web root This is easiest solution to implement. Developer will be tempted to do this. E.G. Application is deployed at location […]

Read More

by , on August 25th, 2017

Posted In: Database, MySQL

MySQL AUTO_INCREMENT column

In case you worked most of life on Oracle DB you must be wondering where is the SEQUENCE. AUTO_INCREMENT column in MySQL is used for primary key column. For each insert MySQL will automatically update the column to next max value. For each new row, MySQL increments the value automatically and persist it to table. […]

Read More

by , on August 24th, 2017

Posted In: IO, Java Core

How to create a temporary file/directory in Java

JDK 7 createTempDirectory and createTempFile method creates temp folder with given suffix. I have also added deleteOnExit to delete temp folder but dir.toFile().deleteOnExit() does not seem to be reliable on Windows. package com.example.java.core; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import org.junit.Test; public class TempFile { @Test public void create() throws Exception { Path dir = […]

Read More

by , on August 24th, 2017

Posted In: Date, Java Core

Convert java.util.Date to java.time.LocalDate, LocalDateTime

Date date1 = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”) .parse(“2017-08-13 12:10:30”); LocalDate localdate = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); LocalDateTime localdatetime = date1.toInstant().atZone(ZoneId.systemDefault()) .toLocalDateTime();

Read More

by , on August 24th, 2017

Posted In: Date, Java Core

Comparing two Dates without the time portion

Techniques used 1. JODA Time DateTimeComparator 2. Apache Commons DateUtils 3. JDK 8 LocalDate 4. Below JDK 8 DateFormat  

Read More

by , on August 24th, 2017

Posted In: Security

How to encrypt Password/String using Bouncy castle library

Bouncy castle library Maven bcprov-jdk16

Read More

by , on August 24th, 2017

Posted In: Apache, Commons, Security

How to encrypt Password/String using Apache Crypto

Apache Crypto library Maven commons-crypto Original Example

Read More

by , on August 24th, 2017

Posted In: Security

How to encrypt Password/String using Jasypt library

Jasypt library provide multiple methods to encrypt a password Maven jasypt

Read More

by , on August 24th, 2017

  • Categories