-------------------------------------------------------------------------------------------------------------------------------------------------------------
必要的四个连接数据库的字符串:
driver=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/stu
user=root
password=lxn123
#driver=oracle.jdbc.driver.OricerDriver
#jdbcUrl=jdbc:oracle:thin:@localhost:1521:orcl
#user=system
#password=lxn123
-------------------------------------------------------------------------------------------------------------------------------------------------------------
person类:
package com.atguigu.javatest;
/*
* FlowID:int,流水号
* type:int ,英语四六级
* IDcard:varchar(18),身份证号码
* examcard:varchar(15),考试证号
* studentname:varchar(20),学生姓名
* localtion:varchar(20),区域
* grade:int,成绩
*/
public class Person {
	private int flowId;
	private int type;
	private String idCard;
	private String examCard;
	private String studentName;
	private String localtion;
	private int grade;
	
	public Person() {
		  super();
	}
	
	public Person(int flowId, int type, String idCard, String examCard, String studentName, String localtion,
			  int grade) {
		  super();
		  this.flowId = flowId;
		  this.type = type;
		  this.idCard = idCard;
		  this.examCard = examCard;
		  this.studentName = studentName;
		  this.localtion = localtion;
		  this.grade = grade;
	}
	
	public int getFlowId() {
		return flowId;
	}
	public void setFlowId(int flowId) {
		this.flowId = flowId;
	}
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getIdCard() {
		return idCard;
	}
	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}
	public String getExamCard() {
		return examCard;
	}
	public void setExamCard(String examCard) {
		this.examCard = examCard;
	}
	public String getStudentName() {
		return studentName;
	}
	public void setStudentName(String studentName) {
		this.studentName = studentName;
	}
	public String getLocaltion() {
		return localtion;
	}
	public void setLocaltion(String localtion) {
		this.localtion = localtion;
	}
	public int getGrade() {
		return grade;
	}
	public void setGrade(int grade) {
		this.grade = grade;
	}
	
	@Override
	public String toString() {
		return "Person [flowId=" + flowId + ", type=" + type + ", idCard=" + idCard + ", examCard=" + examCard
				+ ", studentName=" + studentName + ", localtion=" + localtion + ", grade=" + grade + "]";
	}
	
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------
主页面及实现的功能:
package com.atguigu.javatest;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
import org.junit.Test;
/*连接数据库,并实现增删改查操作的习题
 * 首先导包,然后创建文件jdbc.properties,创建数据库lxn,表test,输入数据
 * FlowID:int,流水号
 * type:int ,英语四六级
 * IDcard:varchar(18),身份证号码
 * examcard:varchar(15),考试证号
 * studentname:varchar(20),学生姓名
 * location:varchar(20),区域
 * grade:int,成绩
 * */
public  class TestConnection {
	static Scanner input=new Scanner(System.in);
	static boolean bb=false;
********************************************************************
	//连接数据库方法
	public static Connection getConnection() throws Exception{
		//四连接数据必不可少的
		String driverClass=null;
		String jdbcUrl=null;
		String user=null;
		String password=null;
		
		InputStream in=
				TestConnection.class.getClassLoader().getResourceAsStream("jdbc.properties");
		//其中getClass与TestConnection.classh互换使用
		Properties properties=new Properties();
		properties.load(in);
		
		driverClass=properties.getProperty("driver");	
		jdbcUrl=properties.getProperty("jdbcUrl");
		user=properties.getProperty("user");
		password=properties.getProperty("password");
		
	//	System.out.println(driverClass+jdbcUrl+user+password);
		Driver driver=(Driver)Class.forName(driverClass).newInstance();
		Properties info=new Properties();
		info.put("user", "root");
		info.put("password", "lxn123");
		Connection connection=driver.connect(jdbcUrl, info);
		return connection;
	}
	//测试类
	public static void testGetConn() throws Exception{
		System.out.println(getConnection());
	}
	*****************************************************************************
	//读取数据库数据,可实现增删改,
	public static void testStatement(String sql) throws Exception{
		//String sql为插入的sql语句
		Connection connection=null;
		Statement statement=null;
		try {
			//获取数据库连接
//			String sql="insert into test(studentName,type,idCard,examCard,localtion,grade) "
//
+ "values(\'studentName\',\'4\',\'idCard\',\'examCard\',\'localtion\',\'93\')";
			connection=getConnection();
			statement=connection.createStatement();
			statement.executeUpdate(sql);
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(statement!=null){
				statement.close();
			}
			if(connection!=null){
				connection.close();
			}
		}
	}
***************************************************************************

