JAVA Practical Programs
Slip 1
[Link] a Java program to display all the alphabets between ‘A’ to ‘Z’ a er every 2 seconds.
public class Slip1_1 extends Thread{
char c;
public void run(){
for(c = 'A'; c<='Z';c++){
[Link](""+c);
try{
[Link](3000);
}
catch(Exception e){
[Link]();
}
}
}
public static void main(String args[]){
Slip1_1 t = new Slip1_1();
[Link]();
}
}
[Link] a Java program to accept the details of Employee (Eno, EName, Designa on,
Salary) from a user and store it into the database. (Use Swing)
import [Link].*;
public class EmployeeDetails {
static final String JDBC_URL = "jdbc:mysql://localhost:3306/practical";
static final String USERNAME = "root";
static final String PASSWORD = "root";
public static void main(String[] args) {
try (Connection conn = [Link](JDBC_URL, USERNAME,
PASSWORD)) {
String eno = promptUser("Enter Employee Number: ");
String ename = promptUser("Enter Employee Name: ");
String designation = promptUser("Enter Employee Designation: ");
double salary = [Link](promptUser("Enter Employee
Salary: "));
insertEmployee(conn, eno, ename, designation, salary);
[Link]("Employee details inserted successfully.");
} catch (SQLException e) {
[Link]();
}
}
private static String promptUser(String message) {
[Link] scanner = new [Link]([Link]);
[Link](message);
return [Link]();
}
private static void insertEmployee(Connection conn, String eno, String
ename, String designation, double salary) throws SQLException {
String sql = "INSERT INTO Employee (Eno, EName, Designation, Salary)
VALUES (?, ?, ?, ?)";
try (PreparedStatement pstmt = [Link](sql)) {
[Link](1, eno);
[Link](2, ename);
[Link](3, designation);
[Link](4, salary);
[Link]();
}
}
}
SQL->
CREATE TABLE Employee (
Eno INT PRIMARY KEY,
EName VARCHAR(255),
Designation VARCHAR(255),
Salary DECIMAL(10, 2)
);
Slip 4
[Link] a Java program using Runnable interface to blink Text on the frame
import [Link].*;
import [Link].*;
public class BlinkingText implements Runnable {
private JLabel label;
public BlinkingText(JLabel label) {
[Link] = label;
}
@Override
public void run() {
try {
while (true) {
[Link](() -> [Link](true));
[Link](500);
[Link](() -> [Link](false));
[Link](500);
}
} catch (InterruptedException e) {
[Link]();
}
}
public static void main(String[] args) {
[Link](() -> {
JFrame frame = new JFrame("Blinking Text");
[Link](300, 200);
[Link](JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("Blinking Text");
[Link]([Link]);
[Link](new Font("Arial", [Link], 20));
[Link](label, [Link]);
BlinkingText blinkingText = new BlinkingText(label);
Thread thread = new Thread(blinkingText);
[Link]();
[Link](true);
});
}
}
[Link] a Java program to store city names and their STD codes using an appropriate collec on and
perform following opera ons: i. Add a new city and its code (No duplicates) ii. Remove a city from
the collec on iii. Search for a city name and display the code
import [Link].*;
public class CityStdCodes {
private Map<String, Integer> cityStdCodes;
public CityStdCodes() {
[Link] = new HashMap<>();
}
public void addCity(String city, int stdCode) {
if () {
[Link](city, stdCode);
[Link]("City '" + city + "' added with STD code: " +
stdCode);
} else {
[Link]("City '" + city + "' already exists with STD
code: " + [Link](city));
}
}
public void removeCity(String city) {
if ([Link](city)) {
[Link](city);
[Link]("City '" + city + "' removed from the
collection.");
} else {
[Link]("City '" + city + "' does not exist in the
collection.");
}
}
public void searchCity(String city) {
if ([Link](city)) {
[Link]("STD code for city '" + city + "' is: " +
[Link](city));
} else {
[Link]("City '" + city + "' not found in the
collection.");
}
}
public static void main(String[] args) {
CityStdCodes cityStdCodes = new CityStdCodes();
[Link]("New York", 212);
[Link]("London", 20);
[Link]("Paris", 33);
[Link]("Tokyo", 81);
[Link]("Paris");
[Link]("Berlin");
[Link]("London");
[Link]("Sydney");
}
}
Slip 6
1. Write a Java program to accept ‘n’ integers from the user and store them in a collec on. Display
them in the sorted order. The collec on should not accept duplicate elements. (Use a suitable
collec on). Search for a par cular element using predefined search method in the Collec on
framework.
import [Link].*;
public class NumberCollection {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
Set<Integer> numbers = new TreeSet<>();
[Link]("Enter the number of integers: ");
int n = [Link]();
[Link]("Enter the integers:");
for (int i = 0; i < n; i++) {
int num = [Link]();
[Link](num);
}
[Link]("Integers in sorted order:");
for (int num : numbers) {
[Link](num + " ");
}
[Link]();
[Link]("Enter the number to search: ");
int searchNum = [Link]();
if ([Link](searchNum)) {
[Link](searchNum + " is found in the collection.");
} else {
[Link](searchNum + " is not found in the
collection.");
}
[Link]();
}
}
2. Write a java program to simulate traffic signal using threads.
public class TrafficSignalSimulation {
enum SignalState {
RED, YELLOW, GREEN
}
static class TrafficSignal {
private SignalState state;
public TrafficSignal() {
[Link] = [Link];
}
public synchronized void changeState() {
switch (state) {
case RED:
state = [Link];
break;
case YELLOW:
state = [Link];
break;
case GREEN:
state = [Link];
break;
}
[Link]("Signal changed to " + state);
notifyAll();
}
public synchronized SignalState getState() {
return state;
}
}
static class Car implements Runnable {
private String name;
private TrafficSignal signal;
public Car(String name, TrafficSignal signal) {
[Link] = name;
[Link] = signal;
}
@Override
public void run() {
while (true) {
synchronized (signal) {
try {
while ([Link]() != [Link]) {
[Link](name + " is waiting at the
signal.");
[Link]();
}
[Link](name + " is crossing the signal.");
[Link](2000);
} catch (InterruptedException e) {
[Link]();
}
}
}
}
}
public static void main(String[] args) {
TrafficSignal signal = new TrafficSignal();
Thread car1 = new Thread(new Car("Car 1", signal));
Thread car2 = new Thread(new Car("Car 2", signal));
Thread car3 = new Thread(new Car("Car 3", signal));
[Link]();
[Link]();
[Link]();
while (true) {
try {
[Link](5000);
[Link]();
} catch (InterruptedException e) {
[Link]();
}
}
}
}
Slip 7
1. Write a java program that implements a mul -thread applica on that has three threads. First
thread generates random integer number a er every one second, if the number is even; second
thread computes the square of that number and print it. If the number is odd, the third thread
computes the of cube of that number and print it.
import [Link];
class Square extends Thread
{
int x;
Square(int n)
{
x = n;
}
public void run()
{
int sqr = x * x;
[Link]("Square of " + x + " = " + sqr );
}
}
class Cube extends Thread
{
int x;
Cube(int n)
{x = n;
}
public void run()
{
int cub = x * x * x;
[Link]("Cube of " + x + " = " + cub );
}
}
class Number extends Thread
{
public void run()
{
Random random = new Random();
for(int i =0; i<10; i++)
{
int randomInteger = [Link](100);
[Link]("Random Integer generated : " + randomInteger);
Square s = new Square(randomInteger);
[Link]();
Cube c = new Cube(randomInteger);
[Link]();
try {
[Link](1000);} catch (InterruptedException ex) {
[Link](ex);
}
}
}
}
public class Slip7_1 {
public static void main(String args[])
{
Number n = new Number();
[Link]();
}
}
[Link] a java program for the following: i. To create a Product(Pid, Pname, Price) table. ii. Insert at
least five records into the table. iii. Display all the records from a table.
import [Link].*;
public class ProductManagement {
static final String JDBC_URL = "jdbc:mysql://localhost:3306/practical";
static final String USERNAME = "root";
static final String PASSWORD = "root";
public static void main(String[] args) {
try {
Connection connection = [Link](JDBC_URL,
USERNAME, PASSWORD);
createProductTable(connection);
insertRecords(connection);
displayRecords(connection);
[Link]();
} catch (SQLException e) {
[Link]();
}
}
private static void createProductTable(Connection connection) throws
SQLException
{
String createTableSQL = "CREATE TABLE IF NOT EXISTS Product (" +
"Pid INT ," +
"Pname VARCHAR(255)," +
"Price DECIMAL(10, 2)" +
")";
Statement statement = [Link]();
[Link](createTableSQL);
[Link]();
}
private static void insertRecords(Connection connection) throws
SQLException {
String insertSQL = "INSERT INTO Product (Pid, Pname, Price) VALUES (?,
?, ?)";
PreparedStatement preparedStatement =
[Link](insertSQL);
Object[][] data = {
{1, "Product A", 10.99},
{2, "Product B", 20.49},
{3, "Product C", 15.79},
{4, "Product D", 30.25},
{5, "Product E", 25.99}
};
for (Object[] row : data) {
[Link](1, (int) row[0]);
[Link](2, (String) row[1]);
[Link](3, (double) row[2]);
[Link]();
}
[Link]();
}
private static void displayRecords(Connection connection) throws
SQLException {
String selectSQL = "SELECT * FROM Product";
Statement statement = [Link]();
ResultSet resultSet = [Link](selectSQL);
ResultSetMetaData metaData = [Link]();
int columnCount = [Link]();
for (int i = 1; i <= columnCount; i++) {
[Link]([Link](i) + "\t");
}
[Link]();
while ([Link]()) {
for (int i = 1; i <= columnCount; i++) {
[Link]([Link](i) + "\t");
}
[Link]();
}
[Link]();
[Link]();
}
}
SQL->
CREATE TABLE IF NOT EXISTS Product (
Pid INT AUTO_INCREMENT PRIMARY KEY,
Pname VARCHAR(255),
Price DECIMAL(10, 2)
);
2)
INSERT INTO Product (Pid, Pname, Price) VALUES
(1, 'Laptop', 999.99),
(2, 'Mobile Phone', 599.99),
(3, 'Headphones', 99.99),
(4, 'Tablet', 399.99),
(5, 'Smartwatch', 199.99);
Slip 13
1. Write a Java program to display informa on about the database and list all the tables in the
database. (Use DatabaseMetaData).
import [Link].*;
public class DatabaseInfo {
static final String JDBC_URL = "jdbc:mysql://localhost:3306/practical";
static final String USERNAME = "root";
static final String PASSWORD = "root";
public static void main(String[] args) {
try {
Connection connection = [Link](JDBC_URL,
USERNAME, PASSWORD);
DatabaseMetaData metaData = [Link]();
[Link]("Database Information:");
[Link]("Database Name: " +
[Link]());
[Link]("Database Version: " +
[Link]());
[Link]();
ResultSet tablesResultSet = [Link](null, null, null,
new String[]{"TABLE"});
[Link]("Tables in the Database:");
while ([Link]()) {
String tableName = [Link]("TABLE_NAME");
[Link](tableName);
}
[Link]();
[Link]();
} catch (SQLException e) {
[Link]();
}
}
}
2. Write a Java program to show lifecycle (crea on, sleep, and dead) of a thread. Program should
print randomly the name of thread and value of sleep me. The name of the thread should be
hard coded through constructor. The sleep me of a thread will be a random integer in the range 0
to 4999
import [Link];
public class ThreadLifecycleDemo extends Thread {
private String threadName;
public ThreadLifecycleDemo(String threadName) {
[Link] = threadName;
}
@Override
public void run() {
[Link](threadName + " is created.");
Random random = new Random();
int sleepTime = [Link](5000);
[Link](threadName + " will sleep for " + sleepTime + "
milliseconds.");
try {
[Link](sleepTime);
} catch (InterruptedException e) {
[Link](threadName + " was interrupted while
sleeping.");
}
[Link](threadName + " is dead.");
}
public static void main(String[] args) {
ThreadLifecycleDemo thread1 = new ThreadLifecycleDemo("Thread 1");
ThreadLifecycleDemo thread2 = new ThreadLifecycleDemo("Thread 2");
ThreadLifecycleDemo thread3 = new ThreadLifecycleDemo("Thread 3");
[Link]();
[Link]();
[Link]();
}
}
Slip 16
1. Write a java program to create a TreeSet, add some colors (String) and print out the content of
TreeSet in ascending order.
import [Link];
public class Slip16_1 {
public static void main(String[] args) {
TreeSet<String> tree_set = new TreeSet<String>();
tree_set.add("Red");
tree_set.add("Green");
tree_set.add("Orange");
tree_set.add("White");
tree_set.add("Black");
[Link]("Tree set: ");
[Link](tree_set);
}
}
2. Write a Java program to accept the details of Teacher (TNo, TName, Subject). Insert at least 5
Records into Teacher Table and display the details of Teacher who is teaching “JAVA” Subject.
(Use PreparedStatement Interface).
import [Link].*;
public class TeacherManagement {
static final String JDBC_URL = "jdbc:mysql://localhost:3306/practical";
static final String USERNAME = "root";
static final String PASSWORD = "root";
public static void main(String[] args) {
try {
Connection connection = [Link](JDBC_URL,
USERNAME, PASSWORD);
insertRecords(connection);
displayJavaTeachers(connection);
[Link]();
} catch (SQLException e) {
[Link]();
}
}
private static void insertRecords(Connection connection) throws
SQLException {
String insertSQL = "INSERT INTO Teacher (TNo, TName, Subject) VALUES
(?, ?, ?)";
PreparedStatement preparedStatement =
[Link](insertSQL);
Object[][] data = {
{1, "John Doe", "JAVA"},
{2, "Jane Smith", "C++"},
{3, "Alice Johnson", "JAVA"},
{4, "Bob Brown", "Python"},
{5, "Emily Davis", "JAVA"}
};
for (Object[] row : data) {
[Link](1, (int) row[0]);
[Link](2, (String) row[1]);
[Link](3, (String) row[2]);
[Link]();
}
[Link]();
}
private static void displayJavaTeachers(Connection connection) throws
SQLException {
String selectSQL = "SELECT * FROM Teacher WHERE Subject = ?";
PreparedStatement preparedStatement =
[Link](selectSQL);
[Link](1, "JAVA");
ResultSet resultSet = [Link]();
[Link]("Teachers teaching JAVA:");
[Link]("TNo\tTName\tSubject");
while ([Link]()) {
int tNo = [Link]("TNo");
String tName = [Link]("TName");
String subject = [Link]("Subject");
[Link](tNo + "\t" + tName + "\t" + subject);
}
[Link]();
[Link]();
}
}
SQL->
CREATE TABLE IF NOT EXISTS Teacher (
TNo INT PRIMARY KEY,
TName VARCHAR(255),
Subject VARCHAR(50)
);
Slip 17
1. Write a java program to accept ‘N’ integers from a user. Store and display integers in sorted
order having proper collec on class. The collec on should not accept duplicate elements.
import [Link].*;
import [Link].*;
class Slip17_1{
public static void main(String[] args) throws Exception{
int no,element,i;
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
TreeSet ts=new TreeSet();
[Link]("Enter the of elements :");
no=[Link]([Link]());
for(i=0;i<no;i++){
[Link]("Enter the element : ");
element=[Link]([Link]());
[Link](element);
}
[Link]("The elements in sorted order :"+ts);
[Link]("Enter element to be serach : ");
element = [Link]([Link]());
if([Link](element))
[Link]("Element is found");
else
[Link]("Element is NOT found");
}
}
2. Write a Mul threading program in java to display the number’s between 1 to 100 con nuously
in a TextField by clicking on bu on. (Use Runnable Interface).
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class MultiThread extends JFrame implements ActionListener
{
Container cc;
JButton b1,b2;
JTextField t1;
MultiThread()
{
setVisible(true);
setSize(1024,768);
cc=getContentPane();
setLayout(null);
t1=new JTextField(500);
[Link](t1);
[Link](10,10,1000,30);
b1=new JButton("start");
[Link](b1);
[Link](20,50,100,40);
[Link](this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if([Link]()==b1)
{
new Mythread();
}
}
class Mythread extends Thread
{
Mythread()
{
start();
}
public void run()
{
for(int i=1;i<=100;i++)
{
try {
[Link](1000);
}
catch (InterruptedException e) {
}
[Link]([Link]()+""+i+"\n");
}
}
}
public static void main(String arg[])
{
new MultiThread().show();
}
}
Slip 21
1. Write a java program to accept ‘N’ Subject Names from a user store them into LinkedList
Collec on and Display them by using Iterator interface.
import [Link].*;
import [Link].*;
public class Slip21_1
{
public static void main(String args[])throws Exception
{
int n;
BufferedReader br = new BufferedReader(new
InputStreamReader([Link]));
LinkedList li = new LinkedList ();
[Link]("\nEnter number of Employee : ");
n = [Link]([Link]());
[Link]("\nEnter name : ");
for(int i = 1; i <= n; i++)
{
[Link]([Link]());
}
[Link]("\nLink List Content : ");
Iterator it = [Link]();
{
[Link]([Link]());
}
[Link]("\nReverse order : ");
ListIterator lt = [Link]();
while([Link]())
{
[Link]();
}
while([Link]())
{
[Link]([Link]());
}
}
}
2. Write a java program to solve producer consumer problem in which a producer produces a value
and consumer consume the value before producer generate the next value. (Hint: use thread
synchroniza on)
import [Link];
public class Threadexample {
public static void main(String[] args)
throws InterruptedException
{
final PC pc = new PC();
Thread t1 = new Thread(new Runnable() {
@Override
public void run()
{
try {
[Link]();
}
catch (InterruptedException e) {
[Link]();
}
}
});
Thread t2 = new Thread(new Runnable() {
@Override
public void run()
{
try {
[Link]();
}
catch (InterruptedException e) {
[Link]();
}
}
});
[Link]();
[Link]();
[Link]();
[Link]();
}
public static class PC {
LinkedList<Integer> list = new LinkedList<>();
int capacity = 2;
public void produce() throws InterruptedException
{
int value = 0;
while (true) {
synchronized (this)
while ([Link]() == capacity)
wait();
[Link]("Producer produced-"
+ value);
[Link](value++);
notify();
[Link](1000);
}
}
}
public void consume() throws InterruptedException
{
while (true) {
synchronized (this)
while ([Link]() == 0)
wait();
int val = [Link]();
[Link]("Consumer consumed-"
+ val);
notify();
[Link](1000);
}
}
}
}
}
Slip 23
[Link] a java program to accept a String from a user and display each vowel from a String a er
every 3 seconds.
import [Link].*;
public class Slip23_1 extends Thread{
String s1;
StringVowels(String s){
s1=s;
start();
}
public void run(){
[Link]("Vowels are :- ");
for(int i=0;i<[Link]();i++ ){
char ch=[Link](i);
if(ch=='a'|| ch=='e'|| ch=='i'|| ch=='o'|| ch=='u'|| ch=='A'||
ch=='E'|| ch=='I'|| ch=='O'|| ch=='U')
[Link](" "+ch);
}
}
public static void main(String args[]) throws Exception{
BufferedReader br = new BufferedReader(new
InputStreamReader([Link]));
[Link]("Enter a string");
String str=[Link]();
StringVowels v=new StringVowels(str);
}
}
2. Write a java program to accept ‘N’ student names through command line, store them into
the appropriate Collec on and display them by using Iterator and ListIterator interface.
import [Link];
import [Link];
import [Link];
public class StudentNames {
public static void main(String[] args) {
if ([Link] == 0) {
[Link]("Please provide student names as command line
arguments.");
return;
}
ArrayList<String> studentList = new ArrayList<>();
for (String arg : args) {
[Link](arg);
}
[Link]("Student names entered:");
displayWithIterator(studentList);
[Link]("\n\nStudent names entered in reverse order:");
displayWithListIterator(studentList);
}
public static void displayWithIterator(ArrayList<String> studentList) {
Iterator<String> iterator = [Link]();
while ([Link]()) {
[Link]([Link]());
}
}
public static void displayWithListIterator(ArrayList<String> studentList)
{
ListIterator<String> listIterator =
[Link]([Link]());
while ([Link]()) {
[Link]([Link]());
}
}
}
Slip 29
1. Write a Java program to display informa on about all columns in the DONAR table using
ResultSetMetaData.
import [Link];
public class LinkedListOperations {
public static void main(String[] args) {
LinkedList<Integer> linkedList = new LinkedList<>();
[Link](10);
[Link](20);
[Link](30);
[Link](5);
[Link]();
int size = [Link]();
[Link]("Size of the LinkedList: " + size);
}
}
2. Write a Java program to create LinkedList of integer objects and perform the following: i.
Add element at first posi on ii. Delete last element iii. Display the size of link list
import [Link].*;
public class DonarTableInfo {
static final String JDBC_URL = "jdbc:mysql://localhost:3306/practical";
static final String USERNAME = "root";
static final String PASSWORD = "root";
public static void main(String[] args) {
try {
Connection connection = [Link](JDBC_URL,
USERNAME, PASSWORD);
DatabaseMetaData metaData = [Link]();
ResultSet resultSet = [Link](null, null, "DONAR",
null);
[Link]("Column Information for DONAR table:");
while ([Link]()) {
String columnName = [Link]("COLUMN_NAME");
String columnType = [Link]("TYPE_NAME");
int columnSize = [Link]("COLUMN_SIZE");
[Link]("Column Name: " + columnName);
[Link]("Column Type: " + columnType);
[Link]("Column Size: " + columnSize);
[Link]();
}
[Link]();
[Link]();
} catch (SQLException e) {
[Link]();
}
}
}
SQL->
INSERT INTO DONAR (Name, BloodGroup, Age, Gender, ContactNumber, Email,
Address)
VALUES ('John Doe', 'O+', 30, 'Male', '1234567890', '[Link]@[Link]',
'123 Main St, City'),
('Jane Smith', 'A-', 25, 'Female', '9876543210',
'[Link]@[Link]', '456 Elm St, Town'),
('Alice Johnson', 'B+', 35, 'Female', '7890123456',
'[Link]@[Link]', '789 Oak St, Village'),
('Bob Brown', 'AB-', 40, 'Male', '6543210987', '[Link]@[Link]',
'321 Maple St, Suburb'),
('Emily Davis', 'A+', 28, 'Female', '4567890123',
'[Link]@[Link]', '987 Pine St, Countryside');
Slip 30
1. Write a java program for the implementa on of synchroniza on.
class Counter {
private int count = 0;
public synchronized void increment() {
count++;
}
public synchronized void decrement() {
count--;
}
public synchronized int getCount() {
return count;
}
}
class CounterThread extends Thread {
private Counter counter;
private boolean increment;
public CounterThread(Counter counter, boolean increment) {
[Link] = counter;
[Link] = increment;
}
public void run() {
if (increment) {
for (int i = 0; i < 1000; i++) {
[Link]();
}
} else {
for (int i = 0; i < 1000; i++) {
[Link]();
}
}
}
}
public class SynchronizationExample {
public static void main(String[] args) throws InterruptedException {
Counter counter = new Counter();
CounterThread incrementThread = new CounterThread(counter, true);
CounterThread decrementThread = new CounterThread(counter, false);
[Link]();
[Link]();
[Link]();
[Link]();
[Link]("Final Counter Value: " + [Link]());
}
}
2. Write a Java Program for the implementa on of scrollable ResultSet. Assume Teacher table
with a ributes (TID, TName, Salary) is already created.
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class ScrollableResultSetExample {
public static void main(String[] args) {
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
connection =
[Link]("jdbc:mysql://localhost/tyjdbc", "root", "root");
statement =
[Link](ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
resultSet = [Link]("SELECT * FROM Teacher");
[Link]();
int rowCount = [Link]();
[Link]();
[Link]("TID\tTName\tSalary");
while ([Link]()) {
int tid = [Link]("TID");
String tname = [Link]("TName");
double salary = [Link]("Salary");
[Link](tid + "\t" + tname + "\t" + salary);
}
[Link]("Total rows: " + rowCount);
} catch (SQLException e) {
[Link]();
} finally {
try {
if (resultSet != null) [Link]();
if (statement != null) [Link]();
if (connection != null) [Link]();
} catch (SQLException e) {
[Link]();
}
}
}
}
SQL->
CREATE TABLE Teacher (
TID INT PRIMARY KEY,
TName VARCHAR(50),
Salary DECIMAL(10, 2)
);
INSERT INTO Teacher (TID, TName, Salary)
VALUES (1, 'John Doe', 50000.00);