Current location - Training Enrollment Network - Books and materials - Library database based on JAVA technology
Library database based on JAVA technology
Import java.awt. *;

Import java.awt.event. *;

Import javax.swing. *;

Import java.sql. *;

Public classroom {

Public static void main(String args[])

{

New street (). The furious ();

}

}

Class interface extension JFrame{

JTextField text 1,text2,text3,text4,text5

JLabel label 1,label2

JTextArea area 1;

JButton button 1;

public void geshi(){

setBounds( 100,50, 1000,700);

set layout(new BorderLayout());

setDefaultCloseOperation(EXIT _ ON _ CLOSE);

JPanel p 1 = new JPanel(new FlowLayout());

text 1 = new JTextField( 10);

text 2 = new JTextField( 10);

label 1 = new JLabel(" ISBN ");

Label2=new JLabel ("author's name");

button 1 = new JButton(" OK ");

Button1.addactionlistener (this));;

p 1 . add(label 1);

p 1 . add(text 1);

p 1 . add(label 2);

p 1 . add(text 2);

p 1 . add(button 1);

Add(p 1, "north");

area 1 = new JTextArea();

text 3 = new JTextField(5);

text 4 = new JTextField(5);

text 5 = new JTextField(5);

Add(text3, "East");

add(area 1," Center ");

add(text4," West ");

Add(text5, "south");

set visible(true);

}

}

Shiqing class implements ActionListener{

jiemian jiemian 1 = null;

Public stone clearing (jiemian jiemian 1)

{

this . Jie mian 1 = Jie mian 1;

}

A public invalid operation was performed (operation event e)

{

//int d = integer . parse int(Jie mian 1 . text 1 . gettext());

String url="jdbc:odbc: Chen Si ";

Try {

class . forname(" sun . JDBC . odbc . JDBC odbc driver ");

}

catch(Java . lang . classnotfoundexception ex)

{

System.out.println ("Unable to load driver");

Return;

}

Try to {//connect to the database.

connection con = driver manager . getconnection(URL," sa "," 775852 1 ");

Statement sm = con.createstatement ();

//sm.execute update ("insert into book values (11,'magazine',' sprout',' Chen Si', null, null, null)");");

//sm.executeUpdate ("deleted from the book bname = 1 1");

ResultSet RS = sm . execute query(" select * from book ");

while(rs.next())

{

string s 1 = RS . getstring( 1);

string S2 = RS . getstring(2);

string S3 = RS . getstring(3);

string S4 = RS . getstring(4);

string S5 = RS . getstring(5);

string S6 = RS . getstring(6);

string S7 = RS . getstring(7);

string S8 = RS . getstring(8);

//Jie mian 1 . area 1 . settext(s 1+" "+S2+" "+S3+" "+S4+" "+S5+" "+S6+" "+S7+" "+S8+" "+" \ n));

if(s 1.trim()。 equals(Jie mian 1 . text 1 . gettext()。 trim()))

{

Jie mian 1 . area 1 . append(s 1+" "+S2+" "+S3+" "+S4+" "+S5+" "+S6+" "+S7+" "+S8+" "+" \ n));

}

}

sm . close();