Skip to content

Instantly share code, notes, and snippets.

Madan Chaudhary madan712

Block or report user

Report or block madan712

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@madan712
madan712 / application.yml
Created Jun 29, 2019
Spring Boot + Jasypt example to encrypted database password in property file
View application.yml
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/schema
username: user
password: ENC(xEOLuBn9FuLgpYl6O8qGwY5MVjr4w2Av)
@madan712
madan712 / Application.java
Last active Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View Application.java
package com.javaxp;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.javaxp.model.Department;
@madan712
madan712 / DepartmentRepository.java
Created Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View DepartmentRepository.java
package com.javaxp.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.javaxp.model.Department;
@Repository
public interface DepartmentRepository extends JpaRepository<Department, Long> {
}
@madan712
madan712 / EmployeeRepository.java
Created Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View EmployeeRepository.java
package com.javaxp.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.javaxp.model.Employee;
@Repository
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
}
@madan712
madan712 / Department.java
Created Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View Department.java
package com.javaxp.model;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@madan712
madan712 / Employee.java
Created Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View Employee.java
package com.javaxp.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@madan712
madan712 / pom.xml
Created Jun 29, 2019
My Sql + Spring Boot JPA - One to many, many to one example
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaxp</groupId>
<artifactId>test-jpa</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test-jpa</name>
<url>http://maven.apache.org</url>
View Application.java
package com.javaxp;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@madan712
madan712 / pom.xml
Created Jun 27, 2019
Java - Export database tables to CSV file
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.javaxp</groupId>
<artifactId>TestExport</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestExport</name>
<url>http://maven.apache.org</url>
@madan712
madan712 / export_db_csv.py
Created Jun 27, 2019
Python - Export database table to csv file
View export_db_csv.py
import mysql.connector
def fetch_table_data(table_name):
# The connect() constructor creates a connection to the MySQL server and returns a MySQLConnection object.
cnx = mysql.connector.connect(
host='localhost',
database='schema',
user='user',
password='password'
You can’t perform that action at this time.