Complete the student management system for the mini version _ 1

Source: Internet
Author: User

/*
* Function:
* Completes the student management system of the mini version.
*/
Import java. AWT .*;
Import javax. Swing .*;
Import java. SQL .*;
Import java. util .*;
Public class sms_1 extends jframe {
// Define the control:
Jpanel jp1, JP2;
Jtable JT;
Jbutton jb1, jb2, jb3, jb4;
Jscrollpane JSP = NULL;
Jtextfield JTF;
// Define the variables required for database operations
Preparedstatement PS = NULL;
Connection Ct = NULL;
Resultset rs = NULL;
Vector columnnames = NULL;
Vector rowdata = NULL;

Public static void main (string [] ARGs ){
Sms_1 SMS = new sms_1 ();

}
Public sms_1 (){

// Column name
Columnnames = new vector ();
Columnnames. Add ("student ID ");
Columnnames. Add ("name ");
Columnnames. Add ("gender ");
Columnnames. Add ("Age ");
Columnnames. Add ("Hometown ");
Columnnames. Add ("don't ");

Rowdata = new vector ();

Try {
// Load the driver
// Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver ");
Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver ");
System. Out. Print ("DF \ n ");
// Link to start
Ct = drivermanager. getconnection ("JDBC: Microsoft: sqlserver: // 127.0.0.1: 1433;" + "databasename = spdbl", "sa", "SQL ");
PS = CT. preparestatement ("select * from Stu ");
Rsw.ps.exe cutequery ();
While (Rs. Next ())
{
// Rowdata can store multiple rows
Vector hang = new vector ();
Hang. Add (Rs. getstring (1 ));
Hang. Add (Rs. getstring (2 ));
Hang. Add (Rs. getstring (3 ));
Hang. Add (Rs. getint (4 ));
Hang. Add (Rs. getstring (5 ));
Hang. Add (Rs. getstring (6 ));

Rowdata. Add (Hang );
}


} Catch (exception e ){
E. printstacktrace ();
// Todo: handle exception
} Finally {
Try {
Rs. Close ();
PS. Close ();
Ct. Close ();

} Catch (exception E2 ){
E2.printstacktrace ();
// Todo: handle exception
}
}
// Initialize jtable
Jt = new jtable (rowdata, columnnames );
// Initialize JSP
JSP = new jscrollpane (JT );
This. Add (JSP );
This. setsize (300,400 );
This. setdefaclocloseoperation (jframe. exit_on_close );
This. setvisible (true );


}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.