import [Link].
*;
public class database_connect {
private ResultSet rs;
private Statement st;
private Connection con;
private void mycon(){
try {
[Link]("[Link]");
con = [Link]("jdbc:odbc:student");
}
catch(ClassNotFoundException e){
[Link]("Class Not Found::");
}
catch(SQLException e1){
[Link]("SQL Error1");
}
}
public void idata(String table, int rno, String name){
try {
mycon();
String query;
int result = 0;
query = "Inserted into" + table + "values(Roll Number, Student Name)" + rno + name;
st = [Link]();
result = [Link](query);
if (result>0)
[Link]("Value inserted");
else
[Link]("Values not inserted");
}
catch(SQLException e){
[Link]("Data not inserted..");
}
}
public ResultSet showall(String table){
try{
mycon();
st = [Link]();
rs = [Link]("select from " + table);
}
catch(SQLException e){
[Link]("SQL Error2");
}
return rs;
}
public static void main(String[] args){
ResultSet rs;
try {
database_connect db1 = new database_connect();
rs=[Link]("std");
[Link]("std",345,"bilal");
while ([Link]()){
[Link]([Link](1) +"\t");
[Link]([Link](2));
}
}
catch(SQLException e2){
[Link]("SQL Error3");
}
}
}
GUI
//[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class window {
static JFrame window = new JFrame();
static JButton b1;
static JCheckBox check;
static JLabel lb;
static Container content = [Link]();
static JTextField txt;
public static void main(String[] args) throws IOException {
// main windows
[Link]("Welcome to my Screen");
[Link](Color.LIGHT_GRAY);
Point center = [Link]().getCenterPoint();
[Link](center.x/4, center.y/4, 1024, 768);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](true);
[Link](false);
FlowLayout layout = new FlowLayout([Link]);
[Link](layout);
//label
lb = new JLabel("Name:");
[Link](lb);
//text field
txt = new JTextField(20);
[Link](txt);
// add button
b1= new JButton("Ok");
[Link](b1);
[Link](100, 50, 200, 200);
// check box
check = new JCheckBox("BSCS",false);
[Link](check);
// action of button
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
String text = [Link]();
File write = new File("[Link]");
PrintWriter writer = new PrintWriter(write);
[Link](text);
}
catch(FileNotFoundException e1){
[Link]();
}
[Link]([Link]);
}
});
//checkbox event
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e){
[Link](false);
}
});
}
}