⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 informodeldb.java

📁 学生成绩管理系统
💻 JAVA
字号:
/*存储学生信息的类*/
package myjava.javaSeries.java.compoent;
import java.sql.*;
import java.util.*;
import java.awt.*;
import myjava.javaSeries.java.compoent.AccessDB;
public class InforModelDB 
{
   AccessDB mydata;
   String num,name;
   float score;
   public InforModelDB()throws SQLException,ClassNotFoundException
	{
     this.mydata=new AccessDB();//建立访问数据库的类实例
   }
   public InforModelDB(String num)throws SQLException,ClassNotFoundException
	{
		this.num=num;
        this.mydata=new AccessDB();
	}
	public InforModelDB(String num,String name)throws SQLException,ClassNotFoundException
	{
		this.num=num;
		this.name=name;
        this.mydata=new AccessDB();
	}
	
	public InforModelDB(String num,String name,float score)throws SQLException,ClassNotFoundException
	{
		this.num=num;
		this.name=name;
		this.score=score;
        this.mydata=new AccessDB();
	}
	public void Insert()throws SQLException//添加记录
	{
		String sqlst="insert into students values('"+num+"','"+name+"','"+score+"')";
		mydata.executeDML(sqlst);
	}
	public void Update()throws SQLException//修改数据库
	{
        String sqlst="update students set name='"+name+"',score='"+score+"' where num='"+num+"'";
		mydata.executeDML(sqlst);
	}
	public void Delete()throws SQLException//删除记录
	{
        String sqlst="delete from students where num='"+num+"'";
		mydata.executeDML(sqlst);
	}
	public ResultSet executeSelect(String sqlst)throws SQLException
	{
		
		return mydata.executeSelect(sqlst);//通过语句对象执行指定的SQL语句,得到结果
		
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -