9.C Write a java program to connect to a database using JDBC and delete values from it.

 import java.sql.*; 

public class result 

{       

public static void main(String[] args)     

{         

Connection con=null;         

PreparedStatement p=null;         

con=connection.connectDB();         

try{             

String sql="delete from cuslogin where id=1";              

p =con.prepareStatement(sql);              

p.execute();         

}

catch(SQLException  e)

{             

System.out.println(e);                      

}     

}      

} 

netaji gandi Sunday, November 15, 2026
9b) a java program to connect to a database using JDBC and insert values into it.

 import java.sql.*;

 import java.awt.*;
 import java.awt.event.*;
 
 public class odbcframe  extends Frame  implements ActionListener
 {
 
    TextField eno;
    TextField ename;
    Button next;
    Button addnew;
 
    Panel p;
    static ResultSet rs;
    static Connection c;
    static Statement st;
 
    public odbcframe()
    {
     super("The query Application:");
     setLayout(new GridLayout(5,1));
     eno=new  TextField(20);
     ename =new TextField(50);
     next =new Button("Next");
     addnew =new Button("AddNewRec");
 
     p=new Panel();
     add(new Label("Emp no:"));
     add(eno);
     add(new Label("Emp name:"));
     add(ename);
     add(p);
     p.add(next);
     p.add(addnew);
 
     next.addActionListener(this);
     addnew.addActionListener(this);
 
     pack();
     setVisible(true);
     }
 
     public static void main(String s[])
     {
     odbcframe obj=new odbcframe();
 
     try
     {  
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     c=DriverManager.getConnection("jdbc:odbc:connect_ora","scott","tiger");
     st=c.createStatement();
      rs=st.executeQuery("select empno,ename from empdet");
     rs.next();
     }
    catch(Exception e)
    {
    System.out.println("Error Inside.."+ e );
    }
    obj.showRecord(rs);
 }
     public void actionPerformed(ActionEvent event)
     {
          if(event.getSource()==next)
          {
               try
               {
                    rs.next();
               }
               catch(Exception e)
               {
               }
               showRecord(rs);
           }
          if(event.getSource()==addnew)
          {
                try
                {
                        addRecord();
                }
               catch(Exception e)
               {
               }
 
         }
 
 
     }
 
     public void showRecord(ResultSet rs)
     {
          try
          {
               eno.setText(rs.getString(1));
               ename.setText(rs.getString(2));
          }
          catch(Exception e)
          {
          }
      }
 
      public void addRecord()
      {
          try
          {
               st.executeUpdate("insert into empdet(empno,ename)  values("+Integer.parseInt(eno.getText())+",'"+ename.getText()+"')");
                          }
          catch(Exception e)
          {
                                       System.out.println(e.toString());
          }
     }
                    
}
 
  

netaji gandi
Exercise-9 A) a java program that connects to a database using JDBC

 public class odbcdriver

{
public static void main(String s[])
{
try
{  
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection c=DriverManager.getConnection("jdbc:odbc:connect_ora","scott","tiger");
     DatabaseMetaData dm=c.getMetaData();
     System.out.println("Data Base Name :"+dm.getDatabaseProductName());
     System.out.println("Versio         :"+dm.getDatabaseProductVersion());
     System.out.println("User Name      :"+dm.getUserName());
     System.out.println("Driver name    :"+dm.getDriverName());
     System.out.println("Driver Version    :"+dm.getDriverVersion());
}
    catch(Exception e)
    {
          System.out.println(e);
    }
}
}

netaji gandi
8c c. Build a Tip Calculator app using several JavaFX components and learn how to respond to user interactions with the GUI.

 import javafx.application.Application;  

import javafx.scene.Group;  

import javafx.scene.Scene;  

import javafx.scene.effect.ImageInput;  

import javafx.scene.image.Image;  

import javafx.scene.paint.Color;  

import javafx.scene.shape.Rectangle;  

import javafx.stage.Stage;  

public class ImageExample extends Application 

{  

    public void start(Stage primaryStage) throws Exception 

    {  

        // TODO Auto-generated method stub  

        Image img = new Image("https://picsum.photos/536/354");  

        ImageInput imginput = new ImageInput();  

        Rectangle rect = new Rectangle();  

        imginput.setSource(img);  

        imginput.setX(20);  

        imginput.setY(100);  

        Group root = new Group();  

        rect.setEffect(imginput);  

        root.getChildren().add(rect);  

        Scene scene = new Scene(root,530,500,Color.BLACK);  

        primaryStage.setScene(scene);  

        primaryStage.setTitle("ImageInput Example");  

        primaryStage.show();  

    }   

    public static void main(String[] args) 

    {  

        launch(args);  

    }   

}   

netaji gandi
8b. Without writing any code, build a GUI that display text in label and image in an ImageView (use JavaFX).

import javafx.application.Application; 

import javafx.scene.Scene; 

import javafx.scene.layout.StackPane; 

import javafx.scene.text.Text; 

import javafx.stage.Stage; 

public class TextExample extends Application
{ 

    public void start(Stage primaryStage) throws Exception 
    { 

        // TODO Auto-generated method stub 

        Text text = new Text(); 

        text.setText("Hello !! Welcome to JavaTPoint"); 

        StackPane root = new StackPane(); 

        Scene scene = new Scene(root,300,400); 

        root.getChildren().add(text); 

        primaryStage.setScene(scene); 

        primaryStage.setTitle("Text Example"); 

        primaryStage.show(); 

    } 

    public static void main(String[] args) 
    { 

        launch(args); 

    } 

} 

netaji gandi

9.C Write a java program to connect to a database using JDBC and delete values from it.

 import java.sql.*;  public class result  {        public static void main(String[] args)      {          Connection con=null;       ...