Skip to content

Instantly share code, notes, and snippets.

View hseritt's full-sized avatar
🏠
Working from home

Harlin Seritt hseritt

🏠
Working from home
View GitHub Profile
@hseritt
hseritt / Start.java
Created June 27, 2016 01:57
Spring MVC controller
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/")
public class Start {
@hseritt
hseritt / AgentRepository.java
Created June 27, 2016 01:56
JPA Repository
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AgentRepository extends JpaRepository<Agent, Long> {
List<Agent> findByActive(boolean active);
}
@hseritt
hseritt / StartPageProperties.java
Created June 27, 2016 01:55
Properties configuration file
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties("web.start")
public class StartPageProperties {
private String appName;
private String pageTitle;
private String templateFolder;
@hseritt
hseritt / Agent.java
Created June 27, 2016 01:54
Jpa Table and Model (unique constraints)
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
@Entity
@hseritt
hseritt / DbConnector.java
Created June 27, 2016 01:54
Creating a database connection and using properties files
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.apache.log4j.Logger;
@hseritt
hseritt / Controller.java
Created June 27, 2016 01:52
Dynamic class instantiation using Thread
public class Controller implements Runnable {
private static Logger logger = Logger.getLogger(Controller.class);
public void run() {
logger.info("Starting subsystem AgentController");
String sql = "select * from agent where active=true";
@hseritt
hseritt / AnyClass.java
Created June 27, 2016 01:51
Create a Logger object
private static Logger logger = Logger.getLogger(BaseAgent.class);