Studentdb.java:
/** * @Title: Studentdb.java * @Package: Com.you.student.system.utils * @Description: * @author: Youhaidong (Zhanghaidong) * @date : 2014-6-16 PM 11:20:51 * @version V1.0 */package com.you.student.system.utils;import java.sql.connection;import Java.sql.preparedstatement;import Java.sql.resultset;import Java.sql.sqlexception;import Java.sql.Timestamp; Import com.you.student.system.model.student;/** * Class function Description * Class modifier Modified Date * Revision Note * <p>Title:StudentDB.java</p> * < ;p >description: Zhanghaidong Personal Development </p> * <p>copyright:copyright (c) 2013</p> * @author: Zhanghaidong * @date: 2014-6-16 Afternoon 11:20:51 * @version V1.0 */public class Studentdb {private Connection conn = null;private PreparedStatement psmt = null; @SuppressWarnings ("unused") private ResultSet rs = null;/** * Get Connection Database * @return The conn */public Connection Getconn () {try {if (This.conn = = NULL | | this.conn.isClosed ()) {Databaseconn db = new Databaseconn (); this.conn = Db.getconn ();}} catch (SQ Lexception e) {e.printstacktrace ();} Return conn;} /** * * @TItle:addstu * @Description: * @param: @param stu * @param: @return * @return: Student * @throws */public Student addstu (stude NT stu) {String sql = ""; String sql0 = ""; try {psmt = This.getconn (). preparestatement (SQL);p smt.setstring (2, Stu.getstuname ());p smt.setstring ( 3, Stu.getstusex ());p Smt.settimestamp (4, New Timestamp (Stu.getbirthday (). GetTime ()));p smt.setstring (5, Stu.getprofessional ());p smt.setdouble (6, Stu.getscore ());p smt.setstring (7, Stu.getremarks ());p Smt.execute ();p SMT = This.getconn (). Preparestatement (sql0);p smt.setstring (1, Stu.getstuname ());p smt.setbytes (2, Stu.getphoto ());} catch (SQLException e) {e.printstacktrace ();} Finally{try {//Close PreparedStatement object Psmt.close ();} catch (SQLException e) {e.printstacktrace ();} try {//Close Connection object Conn.close ();} catch (SQLException e) {e.printstacktrace ()}} return Stu;}}