Menu
Question Index
...


Write a program to get the create table query for Oracle if the entity object is given. Note that you need to use reflection api to do this. Assume that if the entity has field called id, then it is a primary key. The other fields should be sorted by name.

Input (Object) Output (String)
new Student() CREATE TABLE STUDENT(ID NUMBER PRIMARY KEY, GENDER BOOLEAN, MARKS NUMBER, NAME VARCHAR2, PERCENTAGE NUMBER(3, 2), SECTION CHAR);
new Employee() CREATE TABLE EMPLOYEE(ID NUMBER PRIMARY KEY, DESIGNATION VARCHAR2, GENDER BOOLEAN, NAME VARCHAR2, SALARY NUMBER(3, 2));
new Mobile() CREATE TABLE MOBILE(COMPANYNAME VARCHAR2, MEMORY NUMBER(3, 2), MODELNAME VARCHAR2, PIXEL NUMBER(3, 2), PRICE NUMBER(3, 2), RESOLUTION NUMBER);
new College() CREATE TABLE COLLEGE(ADDRESS VARCHAR2, COLLEGECODE VARCHAR2, COLLEGENAME VARCHAR2, NUMBEROFBRANCHES NUMBER, NUMBEROFFACULTY NUMBER, NUMBEROFSTUDENTS NUMBER);

class CreateTableForOracle

{    public static void main(String s[])
    {
        Student student = new Student();
        String query = createTableQuery(student);
        System.out.println(query);

    }


public static String createTableQuery(Object object) {
//Write code here to create a table query for Oracle
}

//If required write any additional methods here
}
class Student {

String name;
boolean gender;
int marks;
double percentage;
char section;
int id;
}

class Employee {

double salary;
String name;
String designation;
int id;
boolean gender;
}

class Mobile {

String companyName;
String modelName;
double price;
double memory;
float pixel;
int resolution;
}

class College {

int numberOfStudents;
int numberOfBranches;
int numberOfFaculty;
String collegeCode;
String address;
String collegeName;
}

Doubts

Problems

Topic: Other Advanced Topics In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App