Student Management System----Student Connection database classes

Source: Internet
Author: User

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> * &lt ;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;}}


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.