Note Taking
Note Taking
import java.util.Scanner;
class Person {
this.name = name;
this.age = age;
return name;
return age;
p.setName(name);
p.setAge(age);
1
JAVA JDBC PROGRAM
package greeb;
/**
* @author Admin
*/
import java.awt.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
TextField t1,t2;
Label l1,l2;
DataInsertion()
setVisible(true);
setSize(400,400);
b1=new Button("Insert");
b2=new Button("Delet");
t1=new TextField(20);
setLayout(new FlowLayout());
add(l1);add(t1);add(b1);add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
System.out.println("Debug-1");
if(ae.getSource()==b1)
String name=t1.getText();
try{
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/
coll","root","mysql"); //here sonoo is database name, root is username and
password
Statement stmt=con.createStatement();
con.close();
catch(ClassNotFoundException | SQLException e)
System.out.println(e);
if(ae.getSource()==b2)
dispose();