Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / applicationContext.xml
Created October 27, 2018 08:29
myFortune question
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
@darbyluv2code
darbyluv2code / StudentControllerServlet.java
Created October 16, 2018 02:13
JSP Course - Student Tracker project updates
package com.luv2code.web.jdbc;
import javax.sql.DataSource;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.RequestDispatcher;
@darbyluv2code
darbyluv2code / MyLoggerConfig.java
Last active March 12, 2023 10:03
Spring Logging for Spring 5.1 - All Java Configuration
package com.luv2code.springdemo;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
@darbyluv2code
darbyluv2code / MyLoggerConfig.java
Last active February 5, 2023 06:34
Spring Logging for Spring 5.1 - XML Configuration
package com.luv2code.springdemo;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class MyLoggerConfig {
@darbyluv2code
darbyluv2code / spring-mvc-crud-demo-servlet.xml
Created September 28, 2018 19:58
1. Since there is no main method in spring, Where and how to load hibernate config xml in Spring Project.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
@darbyluv2code
darbyluv2code / DemoAppConfig.java
Created September 28, 2018 19:57
2. Setup of Spring using Configuration Class instead of xml. Also .. How to use application.properties instead of xml.
package com.luv2code.springdemo.config;
import java.beans.PropertyVetoException;
import java.util.Properties;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
@darbyluv2code
darbyluv2code / ApplicationConfig.java
Created September 24, 2018 17:42
Resolve the issue: HTTP Status 406 – Not Acceptable
package com.hypen.mycare.config;
import java.beans.PropertyVetoException;
import java.util.Properties;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
@darbyluv2code
darbyluv2code / BadDataException.java
Created September 24, 2018 16:10
@ControllerAdvice - multiple exception handlers for single method
package com.luv2code.springdemo.rest;
public class BadDataException extends RuntimeException {
public BadDataException() {
// TODO Auto-generated constructor stub
}
public BadDataException(String message) {
super(message);
@darbyluv2code
darbyluv2code / DemoAppConfig.java
Created September 21, 2018 16:39
Hibernate. addAnnotateClass function
package com.luv2code.springdemo.config;
import java.beans.PropertyVetoException;
import java.util.Properties;
import java.util.logging.Logger;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
@darbyluv2code
darbyluv2code / Steps
Created September 21, 2018 15:31
Connecting to MySQL Database Version 8
Connecting to MySQL Database Server v8 with JDBC Driver, MySQL Connector/J v5.1.x
Starting with MySQL Database Server v8, the MySQL database has changed the default authentication plugin for MySQL server from mysql_native_password to caching_sha2_password.
As a result, you need to make minor changes to the security configuration for your user account. Also, there were some recent critical bug fixes in the 5.1.x JDBC driver, MySQL Connector/J.
1. Download from this link:
JDBC Driver, MySQL Connector/J 5.1.46
https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.zip