Home / Angular / Create Data Table with AngularJS and Spring Boot

Create Data Table with AngularJS and Spring Boot

Step 1: Create Application using spring.io
with Web and SQL and JPA

Step 2: Download and extract zip to local and run mvn clean package in the application directory
it will download the all the dependencies to local

Step3: Setup the Database details in applications.properties located in src/main/resources

server.port:8080
spring.datasource.url=jdbc:mysql://localhost:3306/studentmanagement
spring.datasource.username=root
spring.datasource.password=vamsi1153
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql = false
spring.jpa.hibernate.ddl-auto = update
logging.level.org.springframework.web:error

Step 4:
create a Table in database
Create a JPA Class ( that contains setters and getters )

package com.registration;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name=”student”)
public class Registration {

private Integer id;
private String name;
private Integer age;
private Integer passport_id;

@Id
@GeneratedValue
public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getAge() {
return age;
}

public void setAge(Integer age) {
this.age = age;
}

public Integer getPassport_id() {
return passport_id;
}

public void setPassport_id(Integer passport_id) {
this.passport_id = passport_id;
}

}

create interface

package com.registration;

import org.springframework.data.jpa.repository.JpaRepository;

public interface RegistrationJpa extends JpaRepository {

}

in our Registration Application

package com.registration;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class RegistrationApplication {

@Autowired
private RegistrationJpa registrationJpa;

public static void main(String[] args) {
SpringApplication.run(RegistrationApplication.class, args);
}

@RequestMapping(name=”/getrecords”,consumes=”application/json”,produces=”application/json”)
public List getRecords(@RequestBody RegistrationSequence registrationSequence) throws IOException{

// List list= registrationJpa.findAll();
return new HibernateCallBackImpl(registrationSequence);
}

//
}

About Mohammad Fareed

Software Engineer @ Tekzenit.

Check Also

Object Creation in Java

1)How many ways are there to create an object? 1. How many ways to create …

Leave a Reply

Your email address will not be published. Required fields are marked *