當前位置:首頁 » 編程語言 » 學生管理系統sql源代碼
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

學生管理系統sql源代碼

發布時間: 2023-04-09 21:53:03

⑴ 學生信息管理系統最簡單源代碼。

方法一:

1、創建一個c語言項目。然後右鍵頭文件,創建一個Stu的頭文件。

⑵ (高分)急求連接資料庫的JAVA學生信息管理系統源代碼

資料庫連接(Connection)
資料庫連接
獲取資料庫連接有兩種方法,一種是通過驅動程序管理器DriverManager類,另一種則是使用DataSource介面。這兩種方法都提供了了一個getConnection方法,用戶可以在程序中對它們進行相應處理後調用這個方法來返回資料庫連接。
• DriverManager類
• DataSource介面
• Connection介面
• JDBC URL
jdbc:<subprotocol>:<subname>

• 驅動程序注冊方法
(1)調用Class.forName方法
(2)設置jdbc.drivers系統屬性
• DriverManager方法
DriverManager類中的所有方法都是靜態方法,所以使用DriverManager類的方法時,不必生成實例。
DriverManager
• getConnection方法
作用是用於獲取資料庫連接,原型如下:
public static Connection getConnection(String url)
throws sqlException;

public static Connection getConnection(String url, String user, String password)
throws SQLException;

public static Connection getConnection(String url, Properties info)
throws SQLException;

• 使用DriverManager的getConnetion方法
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection
("jdbc:odbc:sqlserver", "sa", "sa");

• 使用設置jdbc.drivers系統屬性的方法

java -Djdbc.drivers=sun.jdbc.odbc.JdbcOdbcDriver test.java

DataSource 介面
……
//從上下文中查找數據源,並獲取資料庫連接
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("sqlserver");
Connection conn = ds.getConnection();
//查詢資料庫中所有記錄
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM student");
……
Connection 介面
Connection介面代表了已經建立的資料庫連接,它是整個JDBC的核心內容。Connnection介面中的方法按照它們所實現的功能,可以分為三類:
• 生成資料庫語句
• 管理資料庫事務
• 獲取資料庫信息
生成資料庫語句
JDBC將資料庫語句分成三種類型 :
• 生成Statement 語句 :
Connection.createStatement()
• 生成PreparedStatement 語句 :
Connection. prepareStatement()
• 生成CallableStatement 語句 :
Connection. prepareCall ()
管理資料庫事務
• 默認情況下,JDBC將一條資料庫語句視為一個完整的事務。可以關掉默認事務管理:
public void setAutoCommit(Boolean autoCommit) throws SQLException;
將autoCommit的值設置為false,就關掉了自動事務管理模式
• 在執行完事務後,應提交事務:
public void commit() throws SQLException;
• 可以取消事務:
public void rollback() throws SQLException;
第二講 第四部分
資料庫語句
資料庫語句
JDBC資料庫語句共有三種類型:
• Statement:
Statement語句主要用於嵌入一般的SQL語句,包括查詢、更新、插入和刪除等等。
• PreparedStatement:
PreparedStatement語句稱為准備語句,它是將SQL語句中的某些參數暫不指定,而等到執行時在統一指定。
• CallableStatement:
CallableStatement用於執行資料庫的存儲過程。
Statement 語句
• executeQuery方法
• executeUpdate方法
• execute方法
• close方法
executeQuery方法
• executeQuery方法主要用於執行產生單個結果集的SQL查詢語句(QL),即SELECT語句。executeQuery方法的原型如下所示:
• public ResultSet executeQuery(String sql) throws SQLException;
executeUpdate方法
• executeUpdate方法主要用於執行 INSERT、UPDATE、DELETE語句,即SQL的數據操作語句(DML)
• executeUpdate方法也可以執行類似於CREATE TABLE和DROP TABLE語句的SQL數據定義語言(DDL)語句
• executeUpdate方法的返回值是一個整數,指示受影響的行數(即更新計數)。而對於CREATE TABLE 或 DROP TABLE等並不操作特定行的語句,executeUpdate的返回值總為零。
execute方法
execute方法用於執行:
• 返回多個結果集
• 多個更新計數
• 或二者組合的語句
execute方法
• 返回多個結果集:首先要調用getResultSet方法獲得第一個結果集,然後調用適當的getter方法獲取其中的值。要獲得第二個結果集,需要先調用getMoreResults方法,然後再調用getResultSet方法。
• 返回多個更新計數:首先要調用getUpdateCount方法獲得第一更新計數。然後調用getMoreResults,並再次調用getUpdateCount獲得後面的更新計數。
• 不知道返回內容:如果結果是ResultSet對象,則execute方法返回true;如果結果是int類型,則意味著結果是更新計數或執行的語句是DDL命令。
execute方法
為了說明如果處理execute方法返回的結果,下面舉一個代碼例子:
stmt.execute(query);
while (true) {
int row = stmt.getUpdateCount();
//如果是更新計數
if (row > 0) {
System.out.println("更新的行數是:" + row);
stmt.getMoreResults();
continue;
}
execute方法
//如果是DDL命令或0個更新
if (row == 0) {
System.out.println("沒有更新,或SQL語句是一條DDL語句!");
stmt.getMoreResults();
continue;
}
//如果是一個結果集
ResultSet rs = stmt.getResultSet;
if (rs != null) {
while (rs.next()) {
// 處理結果集
. . .
}
stmt.getMoreResults();
continue;
}
break;
}
PreparedStatement 語句
登錄一個網站或BBS時 :
• 使用Statement語句
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery
(「SELECT password FROM userinfo
WHERE id=userId");
• 使用PreparedStatement語句
PreparedStatement pstmt=conn.prepareStatement
(「SELECT password FROM userinfo
WHERE id=?");
pstmt.setString(1, userId);
PreparedStatement語句
• 常用的setter方法

public void setBoolean(int parameterIndex, boolean x) throws SQLException;
public void setByte(int parameterIndex, byte x) throws SQLException;
public void setShort(int parameterIndex, short x) throws SQLException;
public void setInt(int parameterIndex,int x) throws SQLException;
public void setLong(int parameterIndex, long x) throws SQLException;
public void setFloat(int parameterIndex, float x) throws SQLException;
public void setDouble(int parameterIndex, double x) throws SQLException;
public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException;
public void setString(int parameterIndex, String x) throws SQLException;
public void setBytes(int parameterIndex, byte[] x) throws SQLException;
public void setDate(int parameterIndex, Date x) throws SQLException;
public void setTime(int parameterIndex, Time x) hrows SQLException;
public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException;
PreparedStatement語句
• PreparedStatement介面是由Statement介面擴展而來的,重寫了executeQuery方法、executeUpdate方法和execute 方法
• public ResultSet executeQuery() throws SQLException
• public int executeUpdate() throws SQLException
• public boolean execute() throws SQLException
CallableStatement語句
• CallableStatement語句是由Connection介面的prepareCall方法創建的,創建時需要傳入字元串參數,參數的形式為:
• {call procere_name[(?, ?, ...)]}
• {? = call procere_name[(?, ?, ...)]}
• {call procere_name}
CallableStatement語句
• 其中的問號是參數佔位符,參數共有兩種:
• IN參數
• OUT參數
• IN參數使用setter方法來設置
• OUT參數則使用registerOutParameter方法來設置
CallableStatement 語句
CallableStatement cstmt = con.prepareCall
("{call getTestData(?, ?)}");
cstmt.registerOutParameter
(1, java.sql.Types.TINYINT);
cstmt.registerOutParameter
(2, java.sql.Types.DECIMAL, 3);
cstmt.executeQuery();
byte x = cstmt.getByte(1);
java.math.BigDecimal n =
cstmt.getBigDecimal(2, 3);
第二講 第五部分
結 果 集
結果集
• JDBC為了方便處理查詢結果,又專門定義了一個介面,這個介面就是ResultSet介面。ResultSet介面提供了可以訪問資料庫查詢結果的方法,通常稱這個介面所指向的對象為結果集。
• 有兩種方法得到結果集,一種是直接執行查詢語句,將結果存儲在結果集對象上;另一種是不存儲返回結果,而在需要時調用資料庫語句的getResultSet方法來返回結果集
結果集
• 結果集指針
由於返回的結果集可能包含多條數據記錄,因此ResultSet 介面提供了對結果集的所有數據記錄輪詢的方法。結果集自動維護了一個指向當前數據記錄的指針,初始時這個指針是指向第一行的前一個位置。 next 方法就是用於向前移動指針的
結果集
• 結果集屬性
默認情況下,結果集是一個不可更新集,並且結果集的指針也只能向前移動。也就是說,在得到了一個結果集之後,用戶只能按照從第一條記錄到最後一條記錄的順序依次向後讀取,而不能跳到任意條記錄上,也不能返回到前面的記錄。不僅如此,結果集的這種輪詢只能進行一次,而不能再將指針重置到初始位置進行多次輪詢
結果集
• 結果集屬性
類型
並發性
有效性
• 屬性的設置是在生成資料庫語句時通過向生成方法傳入相應的參數設定的,而當結果集已經返回時就不能夠再改變它的屬性了。

結果集生成Statement語句共有三種方法
public Statement createStatement() throws SQLException;
public Statement createStatement
(int resultSetType, int resultSetConcurrency)
throws SQLException;
public Statement createStatement
(int resultSetType, int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
結果集
• 生成PreparedStatement語句共有六種方法

public PreparedStatement prepareStatement(String sql) throws SQLException;
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException;
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
public PreparedStatement prepareStatement(String sql. String[] columnNames)
throws SQLException;
結果集
• 生成CallableStatement語句共有三種方法

public CallableStatement prepareCall(String sql)
throws SQLException;
public CallableStatement prepareCall
(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException;
public CallableStatement prepareCall
(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException;
結果集
結果集類型
• 結果集的類型共有三種,TYPE_FORWARD_ONLY類型的結果集只能向前移動指針,而TYPE_SCROLL_INSENSITIVE類型和TYPE_SCROLL_SENSITIVE類型的結果集則可以任意移動指針。後兩種類型的區別在於,前者對來自其它處的修改不敏感(靜態),而後者則對於別人的修改敏感(動態視圖)。
結果集
結果集類型
• 對於可以任意移動指針的結果集,可以用來移動指針的方法包括:
• next 和previous :
• absolute 和relative :參數可正可負
• afterLast 、beforeFirst 、last 和first :
結果集
結果集並發性
• 結果集的並發性共有兩種,CONCUR_READ_ONLY的結果集是只讀而不可更新的;而CONCUR_UPDATABLE的結果集則是可以通過update方法進行更新的。
• ResultSet介面提供了一組update方法,用於更新結果集中的數據。這些方法與PreparedStatement介面中定義的setter方法一樣,也是與類型相對應的。所有的update方法都以update開頭 。
• 所有的update方法都有兩個參數,第一個參數用於指定更新的列,它可以是列名稱也可以是列的序號;第二個參數則表示將要更新列的值。
結果集
結果集並發性
• Statement stmt = conn.createStatement
• (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
• ResultSet rs = stmt.executeQuery("SELECT * FROM student " +
• "WHERE grade=2 AND math>60 AND physics>60 AND " +
• "chemistry>60 AND english>60 AND chinese>60");
• while(rs.next()){
• rs.updateString("grade", "3");
• rs.updateRow();
• }
結果集
結果集有效性
• 結果集的有效性是指在調用了Connection 介面的commit 方法後,結果集是否自動關閉。所以它只有兩個可選值,即HOLD_CURSORS_OVER_COMMIT 和CLOSE_CURSORS_AT_COMMIT 。前者表示調用commit 方法之後,結果集不關閉;而後者則表示關閉結果集。
結果結果集
• 結果集的getter方法
ResultSet介面還提供了一組getter方法,用於返回當前記錄的屬性值。它們都是以get開頭的,後接數據類型。比如,如果要返回一個float類型的列值,則應調用getFloat方法。每一種類型的getter方法都有兩種形式,它們的名稱相同而參數不同。這兩種形式的getter方法都只有一個參數,第一種形式的getter方法參數是String類型的,用於指定列的名稱;另外一種形式的getter方法參數則是int類型的,用於指定列的序號。

⑶ 急求用vc++連SQL完成的學生教務管理系統。有沒有源代碼或者做好的版本給我參考一下。謝謝啦!

C語言與sql server的旅彎鏈接大鎮凳代碼
#include "stdafx.h"
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include "MainDlg.h"
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#define LOGIN_TIMEOUT 30
#define MAXBUFLEN 255
#define CHECKDBSTMTERROR(hwnd,result,hstmt) if(SQL_ERROR==result){ShowDBStmtError(hwnd,hstmt);return;}
void ShowDBError(HWND hwnd,SQLSMALLINT type,SQLHANDLE sqlHandle);
void ShowDBConnError(HWND hwnd,SQLHDBC hdbc);
void ShowDBStmtError(HWND hwnd,SQLHSTMT hstmt);
void DBTest(HWND hwnd);
BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}
return FALSE;
}
BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
return TRUE;
}
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
DBTest(hwnd);
break;
default:
break;
}
}
void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}
void ShowDBError(HWND hwnd,SQLSMALLINT type,SQLHANDLE sqlHandle)
{
char pStatus[10],pMsg[101];
SQLSMALLINT SQLmsglen;
char error[200]={0};
SQLINTEGER SQLerr;
long erg2=SQLGetDiagRec(type,sqlHandle,1, (SQLCHAR*)pStatus,&SQLerr,(SQLCHAR *)pMsg,100,&SQLmsglen);
wsprintf(error,"%s (%d)\n",pMsg,(int)SQLerr);
MessageBox(hwnd,error,TEXT("資料庫執行錯誤 "),MB_ICONERROR|MB_OK);
}
void ShowDBConnError(HWND hwnd,SQLHDBC hdbc)
{
ShowDBError(hwnd,SQL_HANDLE_DBC,hdbc);
}
void ShowDBStmtError(HWND hwnd,SQLHSTMT hstmt)
{
ShowDBError(hwnd,SQL_HANDLE_STMT,hstmt);
}

void DBTest(HWND hwnd)
{
SQLHENV henv=NULL;
SQLHDBC hdbc=NULL; //代表一個資料庫滾旅連接
SQLHSTMT hstmt=NULL;
SQLRETURN result;
SQLCHAR ConnStrIn[MAXBUFLEN]="DRIVER={SQL Server};SERVER=127.0.0.1;UID=sa;PWD=19920035;DATABASE=testdb;CharSet =gbk;";//這里設置資料庫
SQLCHAR ConnStrOut[MAXBUFLEN];
//分配環境句柄
result=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE, &henv);
//設置管理環境屬性
result=SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3,0);
//分配連接句柄
result=SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
//設置連接屬性
result=SQLSetConnectAttr(hdbc,SQL_LOGIN_TIMEOUT, (void*)LOGIN_TIMEOUT,0);
//連接資料庫
result=SQLDriverConnect(hdbc,NULL,
ConnStrIn,SQL_NTS,
ConnStrOut,MAXBUFLEN,
(SQLSMALLINT *)0,SQL_DRIVER_NOPROMPT);
if(SQL_ERROR==result)
{
ShowDBConnError(hwnd,hdbc);
return;
}
//初始化語句句柄
result=SQLAllocHandle(SQL_HANDLE_STMT,hdbc,&hstmt);
//SQL_-Terminated String,
//
result=SQLPrepare(hstmt,(SQLCHAR*)/*(這里寫SQL語句)*/,SQL_NTS);
CHECKDBSTMTERROR(hwnd,result,hstmt);
result=SQLExecute(hstmt);
CHECKDBSTMTERROR(hwnd,result,hstmt);
SQLFreeStmt(hstmt,SQL_CLOSE);
SQLDisconnect(hdbc);
SQLFreeHandle(SQL_HANDLE_DBC,hdbc);
SQLFreeHandle(SQL_HANDLE_ENV,henv);
MessageBox(hwnd,TEXT("執行成功"),TEXT("標題"),MB_OK);
}

⑷ 急求java學生信息管理系統源代碼,帶有連接資料庫的,萬分感謝

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;
public class MainFrame extends JFrame implements ActionListener{
InsertPanel ip = null;
SelectPanel sp = null;
JPanel pframe;
JButton jb1,jb2,jb3;
JMenuItem jm11,jm21,jm22,jm23,jm31,jm32,jm41,jm42;
CardLayout clayout;
public MainFrame(String s){
super(s);
JMenuBar mb = new JMenuBar();
this.setJMenuBar(mb);
JMenu m1 = new JMenu("系統");
JMenu m2 = new JMenu("基本信息");
JMenu m3 = new JMenu("成績");
JMenu m4 = new JMenu("獎懲");
mb.add(m1);
mb.add(m2);
mb.add(m3);
mb.add(m4);
jm11 = new JMenuItem("退源脊出系統");
jm21 = new JMenuItem("輸入");
jm22 = new JMenuItem("查詢");
jm23 = new JMenuItem("更改");
jm31 = new JMenuItem("輸入成績渣裂兄");
jm32 = new JMenuItem("查如襲詢成績");
jm41 = new JMenuItem("獎勵");
jm42 = new JMenuItem("處分");
m1.add(jm11);
m2.add(jm21);
m2.add(jm22);
m2.add(jm23);
m3.add(jm31);
m3.add(jm32);
m4.add(jm41);
m4.add(jm42);
Icon i1 = new ImageIcon();
Icon i2 = new ImageIcon();
Icon i3 = new ImageIcon();
jb1 = new JButton(i1);
jb1.setToolTipText("輸入");
jb2 = new JButton(i2);
jb2.setToolTipText("查詢");
jb3 = new JButton(i3);
jb3.setToolTipText("退出");
JToolBar tb = new JToolBar("系統工具");
tb.add(jb1);
tb.add(jb2);
tb.add(jb3);
add(tb,BorderLayout.NORTH);
jm11.addActionListener(this);
jm21.addActionListener(this);
jm22.addActionListener(this);
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
clayout = new CardLayout();
pframe = new JPanel(clayout);
add(pframe);
JPanel mainp = new JPanel(new BorderLayout());
JLabel mainl = new JLabel("學生信息管理平台",SwingConstants.CENTER);
mainl.setFont(new Font("serif",Font.BOLD,30));
mainp.add(mainl);
pframe.add(mainp,"main");
clayout.show(pframe, "main");
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jm21 || e.getSource() == jb1){
if(ip == null){
ip= new InsertPanel();
pframe.add(ip,"insert");
}
clayout.show(pframe, "insert");
this.setTitle("輸入學生信息");
}
else if(e.getSource() == jm22 || e.getSource() == jb2){
if(sp == null){
sp= new SelectPanel();
pframe.add(sp,"select");
}
clayout.show(pframe, "select");
this.setTitle("查詢學生信息");
}
else if(e.getSource() == jm11 || e.getSource() == jb3){
System.exit(0);
}
}
}
第二個:
import javax.swing.JFrame;
public class MainTest {
public static void main(String [] args){
MainFrame f = new MainFrame("學生信息管理平台");
f.setSize(400,300);
f.setLocation(350,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第二個:
import java.sql.Connection;
import java.sql.DriverManager;
public class MySQLConnection {
static Connection getCon(){
Connection con = null;
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","123");
}
catch(Exception e){
System.out.println("建立資料庫連接遇到異常!");
}
return con;
}
}
第四個:
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class SelectPanel extends JPanel implements ActionListener{
JButton jb;
JTextField jt;
JTextField jt1,jt2,jt3,jt4;
public SelectPanel(){
JLabel jl = new JLabel("請輸入學號:",SwingConstants.CENTER);
jt = new JTextField();
jb = new JButton("確定");
JPanel jp1 = new JPanel(new GridLayout(1,3));
jp1.add(jl);
jp1.add(jt);
jp1.add(jb);
JLabel j1,j2,j3,j4;
j1 = new JLabel("學號:",SwingConstants.CENTER);
j2 = new JLabel("姓名:",SwingConstants.CENTER);
j3 = new JLabel("性別:",SwingConstants.CENTER);
j4 = new JLabel("年齡:",SwingConstants.CENTER);
jt1 = new JTextField(6);
jt1.setEditable(false);
jt2 = new JTextField(6);
jt2.setEditable(false);
jt3 = new JTextField(6);
jt3.setEditable(false);
jt4 = new JTextField(6);
jt4.setEditable(false);
JPanel jp2 = new JPanel(new BorderLayout());
JPanel jp3 = new JPanel(new GridLayout(4,2));
jp2.add(new JLabel(""),BorderLayout.NORTH);
jp3.add(j1);
jp3.add(jt1);
jp3.add(j2);
jp3.add(jt2);
jp3.add(j3);
jp3.add(jt3);
jp3.add(j4);
jp3.add(jt4);
jp2.add(jp3);
this.setLayout(new BorderLayout());
add(jp1,BorderLayout.NORTH);
add(jp2);
jb.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == jb){
String stuNo = jt.getText().trim();
Student s = new Student();
boolean b = true;
try{
b = s.selectByStuNo(stuNo);
}
catch(Exception ex){
System.out.println("查詢學生信息遇到異常!");
}
if(b){
jt1.setText(s.getStuNo());
jt2.setText(s.getName());
jt3.setText(s.getGender());
int a = s.getAge();
Integer i = new Integer(a);
jt4.setText(i.toString());
}
else{
JOptionPane.showMessageDialog(null, "無此學生!");
}
}
}

}
第五個:
import javax.swing.JFrame;
public class SelectTest {
public static void main(String [] args){
JFrame f = new JFrame("查詢學生信息");
SelectPanel p = new SelectPanel();
f.add(p);
f.setSize(400,300);
f.setLocation(300,250);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
}
}
第六個:
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
public class Student {
String stuNo;
String name;
String gender;
int age;
public Student(){}
public Student(String stuNo,String name,String gender, int age){
this.stuNo = stuNo;
this.name = name;
this.gender = gender;
this.age = age;
}
public String getStuNo(){
return stuNo;
}
public void setStuNo(String stuNo){
this.stuNo = stuNo;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getGender(){
return gender;
}
public void setGender(String gender){
this.gender = gender;
}
public int getAge(){
return age;
}
public void setAge(int age){
this.age = age;
}
public boolean insertStudent(){
boolean b = true;
try{
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "insert into student values('" + stuNo + "','" + name +"','" + gender + "'," + age + ")";
sql = new String(sql.getBytes("gb2312"),"ISO8859_1");
statement.executeUpdate(sql);
con.close();
}
catch(Exception e){
b = false;
System.out.println("插入資料庫遇到異常!");
}
return b;
}
public boolean selectByStuNo(String stuNo)throws Exception{
boolean b = true;
Connection con = MySQLConnection.getCon();
Statement statement = con.createStatement();
String sql = "select * from student where stuNo =" + stuNo;
ResultSet rs = statement.executeQuery(sql);
if(rs != null && rs.next()){
String no = rs.getString(1);
this.setStuNo(no);
String n = rs.getString(2);
n = new String(n.getBytes("ISO8859_1"),"gb2312");
this.setName(n);
String g = rs.getString(3);
g = new String (g.getBytes("ISO8859_1"),"gb2312");
this.setGender(g);
this.setAge(rs.getInt(4));
b = true;
}
rs.close();
statement.close();
con.close();
return b;
}
}
資料庫你自己弄吧,我沒時間弄了!初學得多動手哦

⑸ SQL學生信息管理系統 存儲過程怎麼寫代碼 要一個刪除操作的 還有觸發器的刪除操作代碼 並求講解下 ,感謝!

刪除雹扮孫數據 delete table_name where .......
刪除源鏈表 drop table table_name

觸發器
create trigger trigger_name on table_name
for delete
as
begin
--具體觸發缺念器處理
end

⑹ 在資料庫 學生管理系統 中使用SQL語句編寫:查看所有女學生的學號,姓名,

語句如下:

SELECT學號,姓名,性別,出生日期
FROM學生管理系統資料庫
WHERE性別='女'
ORDERBY學號asc

⑺ 求大佬救救孩子 sql server資料庫 下面幾個問題,代碼該怎麼打

其中編號為了方便使用id作為編號,實際運用中編號應該用特定的格式,以上語句中id設置為了主鍵,保證了編號的唯一性。

第一條查詢,查詢某個學生的信息;該語句中使用了學號來查詢學生的信息,也可改為其他條件。

select s.student_id as 學號,

s.student_name as 姓名,

s.sex as 性別,

s.house_address as 家庭地址,

s.phone as 聯系電話,

c.class_name as 班級名稱,

m.major_name as 專業名稱,

g.grade_name as 年級名稱,

d.department_name as 系部名稱

from student s left join class c on s.class_id=c.class_id

left join major m on c.major_id = m.major_id left join grade g on m.grade_id=g.grade_id

left join department d on m.department_id=d.department_id

where s.student_id=1

第二條:查詢某個輔導員班級的學生成績

select c.class_name as 班級名稱,

s.student_id as 學號,

s.student_name as 姓名,

cr.course_name as 課程名稱,

p.performance as 成績

from class c left join student s on s.class_id=c.class_id

left join performance p on s.student_id=p.student_id

left join course cr on p.course_id =cr.course_id

where instructor ='王子亮』

第三條:查詢某個協會的學生,根據協會的名稱查詢

select mo.mass_organization_name as 協會名稱,

s.student_name as 姓名,

s.sex as 性別,

s.house_address as 家庭地址,

s.phone as 聯系電話,

c.class_name as 班級名稱,

m.major_name as 專業名稱,

g.grade_name as 年級名稱,

d.department_name as 系部名稱

from mass_organization mo left join student s on mo.mass_organization_id=s.mass_organization_id

left join class c on s.class_id=c.class_id

left join major m on c.major_id = m.major_id left join grade g on m.grade_id=g.grade_id

left join department d on m.department_id=d.department_id

where mass_organization_name='音樂協會』

由於沒有畫圖工具,E-R圖暫不畫出。

結果三

⑻ 求用sql sever 2000實現的學生管理系統或者宿舍管理系統的源代碼

你們學校教材都那麼死嗎,都什麼年代了,還用2000?

⑼ 學生成績管理系統源代碼 SQL+JAVA

這個東西,雖說很簡單,但是也會費點時間,還是建議花錢買吧,這樣要,不會有幾個人會專門去給你寫的,除非他之前寫過類似的課程設計。

⑽ 如何用SQL建立一個學生成績管理系統資料庫

首先在SQL中利用企業管理器或向導建立一個資料庫,命名為學生管理系統,
啟動SQL Sever服務,運行企業管理器,單擊要創建資料庫的伺服器左邊的加號圖標,展開樹形目錄,在「資料庫」節點上右擊滑鼠,在彈出的快捷菜單中選則「新建資料庫」命令,然後按照提示一步步建立資料庫,不再詳細敘述。

假設學生管理系統下有三個表,分別為學生表、課程表、修課表,表的結構分別如下:
學生表(student) (
學號(sno) 普通編碼定長字元類型,長度7,主碼,
姓名(sname) 普通編碼定長字元類型,長度8,非空,
性別(ssex) 統一編碼定長字元類型,長度1,
年齡(sage) 微整型,
所在系(sdept) 統一編碼可變長字元類型,長度20


課程表(course) (
課程號(cno) 普通編碼定長字元類型,長度6,主碼,
課程名(cname) 統一編碼定長字元類型,長度10,非空,
學分(credit) 小整型,
學期(semester) 小整型


修課表(sc)(
學號(sno) 普通編碼定長字元類型,長度7,主碼,外碼
課程號(cno) 普通編碼定長字元類型,長度6,主碼,外碼
成績(grade) 小整型,
修課類別(type)普通編碼定長字元類型,長度4


則創建表的語句分別為:
create table Student(
Sno char(7) primary key,
Sname char(8) not null,
Ssex nchar(1),
Sage tinyint,
Sdept nvarchar(20)
)

create table Course(
Cno char(6) primary key,
Cname nchar(10) not null,
Credit smallint,
Semester smallint
)

create table SC(
Sno char(7),
Cno char(6),
Grade smallint,
Type char(4),
primary key(Sno,Cno),
Foreign key(Sno) References Student (Sno),
Foreign key(Cno) References Course (Cno)
)

各表的結構大體如此,如有變化可自行修改。 以上資料庫和表就基本建立好了,然後就可以通過數據導入或SQL語句等向資料庫中添加學生的各項具體數據了。