Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:24:47+00:00 2026-06-14T19:24:47+00:00

//JDBC using Applet /* <applet code = JDBC1 height = 170 width = 350

  • 0
//JDBC using Applet
/*
<applet code = JDBC1 height = 170 width = 350 >
</applet>
*/

import javax.swing.*; //JApplet,JLabel,JButton

import java.applet.*; //Applet
import java.awt.*; //Layout

import java.awt.event.*; //Events

import java.sql.*; //JDBC

public class JDBC1 extends Applet implements Runnable,ActionListener
{
JFrame frame ;
JPanel panel1;
JLabel lblNo,lblName,lblBdate ;
JTextField txtNo,txtName,txtBdate;
JButton btn;

Statement st1;
Connection cn;
ResultSet rs;

    public JDBC1()
    {
        try
        {
            panel1 = new JPanel ();
            panel1.setLayout(new GridLayout(0,2));

            lblNo = new JLabel ("Roll No : ");
            panel1.add(lblNo);

            txtNo = new JTextField(15);
            panel1.add(txtNo);

            lblName = new JLabel ("Name : ");
            panel1.add(lblName);

            txtName = new JTextField(15);
            panel1.add(txtName);

            lblBdate = new JLabel ("Birth Date : ");
            panel1.add(lblBdate);

            txtBdate = new JTextField(15);
            panel1.add(txtBdate); //Add textarea to the panel.

            add(panel1); //Add panel to the aaplet.

            btn = new JButton ("First");
            add(btn); //Add button to the applet.
            btn.addActionListener(this);

            btn = new JButton ("Next");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Last");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Prev");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Save");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Reset");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Delete");
            add(btn);
            btn.addActionListener(this);

            btn = new JButton ("Update");
            add(btn);
            btn.addActionListener(this);

            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //Load the JDBC-ODBC bridge driver
            cn = DriverManager.getConnection("jdbc:odbc:STUDENT_MYDSN"); // conection to databse

            st1 = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

            String query = "select * from Student";
            rs = st1.executeQuery(query);

        }

        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void init()
    {
        try
        {
            Thread th = new Thread (this);
            th.start(); 
        }
        catch(Exception ex)
        {
            System.out.println(ex.toString());
        }
    }


    public void run ()
    {
        try
        {

            while(true)
            {
                JDBC1 my = new JDBC1();
                repaint();
                Thread.sleep(1000);
            }
        }
        catch(Exception ex)
        {
            System.out.println(ex.toString());
        }
    }

    public void paint (Graphics g)
    {
        super.paint(g);
        java.util.Date dt = new java.util.Date();
        String myDate = dt+"";
        g.drawString(myDate,100,150);
    }

    void getRecord()
    {
        try
        {
            txtNo.setText((String) rs.getObject(1));
        }

        catch (Exception e)
        {
            System.out.println(e.toString());
        }
    }

    public void actionPerformed(ActionEvent e)
    {
        try
        {
            String name = ((JButton) e.getSource()).getText();

            if (name == "First")
            {

                System.out.println("First");
            }

            if (name == "Prev")
            {
                System.out.println("Prev");
            }

            if (name == "Next")
            {
                System.out.println("Next");
            }

            if (name == "Last")
            {
                System.out.println("First");
            }

            if (name == "Save")
            {
                System.out.println("First");
            }

            if (name == "Delete")
            {
                System.out.println("First");
            }

            if (name == "Update")
            {
                System.out.println("First");
            }

            if (name == "Reset")
            {
                System.out.println("First");
            }
        }

        catch (Exception ex)
        {
            System.out.println(ex.toString());
            ex.printStackTrace();
        }
    }

}

By using this Applet with JDBC , I will getting below error

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "file.encoding"
            at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
            at java.security.AccessController.checkPermission(AccessController.java:560)
            at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
            at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
            at java.lang.System.getProperty(System.java:706)
            at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:142)
            at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
            at java.sql.DriverManager.getConnection(DriverManager.java:579)
            at java.sql.DriverManager.getConnection(DriverManager.java:243)
            at JDBC1.<init>(JDBC1.java:87)
            at JDBC1.run(JDBC1.java:123)
            at java.lang.Thread.run(Thread.java:722)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:24:51+00:00Added an answer on June 14, 2026 at 7:24 pm

    You won’t be able to run JDBC in an applet without taking steps to give the applet appropriate permissions. The topic is covered in detail by this tutorial from Oracle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using JDBC Authentication service for my security. code of authentication provider is
Our standard code section for using JDBC is... Connection conn = getConnection(...); Statement stmt
I have a persistence.xml file using JDBC, working fine, but the code updates the
I made some Java 1.6-Oracle11g-JDBC (using OJDBC 6) code (below). I am getting an
I'm using JDBC Connection pooling with mysql. This is my code private static DataSource
I am using jdbc to select data from a mysql database. I am performing
I am using JDBC to query a MySQL database for specific records from two
I have a java-application using JDBC for database interaction. I want to do a
I'm new to using JDBC + MySQL. I have several 1/0 values which I
Why when I'm using jdbc to do inserts into my data base my table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.