Quantum Internet Benefits

Image
  The quantum internet is a network of quantum computers that are connected together using quantum communication. It has the potential to revolutionize many industries, including: Secure communications: The quantum internet would be inherently secure, as it would be impossible to eavesdrop on quantum communications without being detected. This could be used for applications such as secure financial transactions, government communications, and military applications. Quantum computing: The quantum internet would allow quantum computers to be connected together, which would allow them to solve problems that are currently impossible for classical computers. This could be used for applications such as drug discovery, financial modeling, artificial intelligence, and materials science. Quantum sensors: The quantum internet could be used to connect quantum sensors together, which would allow them to create a global network of sensors that could be used to monitor the environment, detect earthq

Java Swing MySql JDBC: insert data into database

Program

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class insertswing implements ActionListener
{
  JFrame fr;JPanel po;
  JLabel l1,l2,main;
  JTextField tf1,tf2;
  GridBagConstraints gbc;
  GridBagLayout go;
  JButton ok,exit;

public insertswing(){
fr=new JFrame("New User Data ");
Font f=new Font("Verdana",Font.BOLD,24);
po=new JPanel();
fr.getContentPane().add(po);
fr.setVisible(true);
fr.setSize(1024,768);
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
po.setBackground(Color.WHITE);
go=new GridBagLayout();
gbc=new GridBagConstraints();
po.setLayout(go);
main=new JLabel("Enter User Details ");
main.setFont(f);
l1=new JLabel("Name  :");tf1=new JTextField(20);
l2=new JLabel("User Name  :");tf2=new JTextField(20);
ok=new JButton("Accept");
exit=new JButton("Exit");

gbc.anchor=GridBagConstraints.NORTH;gbc.gridx=5;gbc.gridy=0;
go.setConstraints(l1,gbc);po.add(main);

gbc.anchor=GridBagConstraints.WEST;gbc.gridx=5;
gbc.gridy=5;go.setConstraints(l1,gbc);po.add(l1);


gbc.anchor=GridBagConstraints.WEST;gbc.gridx=10;gbc.gridy=5;
go.setConstraints(tf1,gbc);po.add(tf1);

gbc.anchor=GridBagConstraints.WEST;gbc.gridx=5;gbc.gridy=10;
go.setConstraints(l2,gbc);po.add(l2);

gbc.anchor=GridBagConstraints.WEST;gbc.gridx=10;
gbc.gridy=10;go.setConstraints(tf2,gbc);po.add(tf2);

gbc.anchor=GridBagConstraints.WEST;gbc.gridx=10;gbc.gridy=90;
go.setConstraints(ok,gbc);po.add(ok);ok.addActionListener(this);

gbc.anchor=GridBagConstraints.WEST;gbc.gridx=11;gbc.gridy=90;
go.setConstraints(exit,gbc);po.add(exit);
exit.addActionListener(this);

}

@Override
public void actionPerformed(ActionEvent ev)
{
    if(ev.getSource()==ok)

    {
        try{
Connection con;JLabel last =new JLabel("Data inserted successfully");
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection
("jdbc:mysql://localhost/userDB","root","root");
 PreparedStatement ps=con.prepareStatement
("Insert into usertbl values(default,?,?)");
String id=tf1.getText();String sname=tf2.getText();
ps.setString(1,id);ps.setString(2,sname);
ps.executeUpdate();con.close();
tf1.setText("");tf2.setText("");
    JOptionPane.showMessageDialog(fr, "Data inserted successfully.");
        }
catch(Exception e){
    System.out.println("ERROR  "+e);
}
    }
if(ev.getSource() == exit){fr.dispose();

}
}


    public static void main(String a[]){
    new insertswing();
    }

}






output

 1. Adding values and data inserted successfully popup message




 2. Checking inserted value in database table


Comments

Popular posts from this blog

Jsp / Java Password Encrypt and Decrypt Example

SQL Script : Adventure works database setup and Select query, list of tables #100daysofsql

How to Hide Gridview and Show the selected gridview row details in Form View using ASP.NET C#