db

原创 2015年11月18日 17:09:30
package com.liyang.table;

import com.alibaba.fastjson.JSONObject;
import com.liyang.annotation.Column;
import com.liyang.annotation.Entity;

/*

DROP TABLE IF EXISTS `Tteam`;  
CREATE TABLE `Tteam` (  
 `vc_teamname` varchar(20) NOT NULL,  
 `vc_stuno1` varchar(20) NOT NULL,   
 `vc_stuname1` varchar(20) NOT NULL,  
 `vc_state1` enum("确认","未确认"),   
 `vc_stuno2`  varchar(20) ,  
 `vc_stuname2` varchar(20) ,  
 `vc_state2`  enum("确认","未确认"),   
 `vc_stuno3`  varchar(20) ,  
 `vc_stuname3`  varchar(20) ,  
 `vc_state3`  enum("确认","未确认"),   
 `vc_isgirls`  enum("是","否"),  
 `vc_state`  enum("通过","拒绝"),  
 `vc_date`  date ,
 PRIMARY KEY (`vc_teamname`)  
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;  

*/

@Entity(name = "Tteam")
public class Team {

       @Column(name = "vc_teamname")
       private  String  TeamName  ;

       @Column(name = "vc_stuno1")
       private  String  StuNo1  ; 

       @Column(name = "vc_stuname1")
       private  String  StuName1  ; 

       @Column(name = "vc_state1")
       private  String  State1 ;

       @Column(name = "vc_stuno2")
       private  String  StuNo2 ; 

       @Column(name = "vc_stuname2")
       private  String  StuName2  ;

       @Column(name = "vc_state2")
       private  String  State2 ;

       @Column(name = "vc_stuno3")
       private  String  StuNo3 ; 

       @Column(name = "vc_stuname3")
       private  String  StuName3  ;

       @Column(name = "vc_state3")
       private  String  State3  ;

       @Column(name = "vc_isgirls")
       private  String  Isgirls ;

       @Column(name = "vc_state")
       private  String  State ;

       @Column(name = "vc_date")
       private  String  Date ;

    public String getTeamName() {
        return TeamName;
    }

    public void setTeamName(String teamName) {
        TeamName = teamName;
    }

    public String getStuNo1() {
        return StuNo1;
    }

    public void setStuNo1(String stuNo1) {
        StuNo1 = stuNo1;
    }

    public String getStuName1() {
        return StuName1;
    }

    public void setStuName1(String stuName1) {
        StuName1 = stuName1;
    }

    public String getState1() {
        return State1;
    }

    public void setState1(String state1) {
        State1 = state1;
    }

    public String getStuNo2() {
        return StuNo2;
    }

    public void setStuNo2(String stuNo2) {
        StuNo2 = stuNo2;
    }

    public String getStuName2() {
        return StuName2;
    }

    public void setStuName2(String stuName2) {
        StuName2 = stuName2;
    }

    public String getState2() {
        return State2;
    }

    public void setState2(String state2) {
        State2 = state2;
    }

    public String getStuNo3() {
        return StuNo3;
    }

    public void setStuNo3(String stuNo3) {
        StuNo3 = stuNo3;
    }

    public String getStuName3() {
        return StuName3;
    }

    public void setStuName3(String stuName3) {
        StuName3 = stuName3;
    }

    public String getState3() {
        return State3;
    }

    public void setState3(String state3) {
        State3 = state3;
    }

    public String getIsgirls() {
        return Isgirls;
    }

    public void setIsgirls(String isgirls) {
        Isgirls = isgirls;
    }

    public String getState() {
        return State;
    }

    public void setState(String state) {
        State = state;
    }

    public String getDate() {
        return Date;
    }

    public void setDate(String date) {
        Date = date;
    }


    @Override
    public String toString() {
        // TODO Auto-generated method stub
            return JSONObject.toJSONString(this) ;
    }
}
package com.liyang.table;

import com.alibaba.fastjson.JSONObject;
import com.liyang.annotation.Column;
import com.liyang.annotation.Entity;
/*

DROP TABLE IF EXISTS `Tstudent`;  
CREATE TABLE `Tstudent` (  
  `vc_no` varchar(20) NOT NULL,  
  `vc_name` varchar(20) NOT NULL,  
  `vc_sex` enum("男","女") ,  
   `vc_education` enum("本科","硕士") ,  
  `vc_profession`  varchar(20) NOT NULL,  
  `vc_tel`  varchar(20) NOT NULL,  
  `vc_schoolyear`  varchar(20) NOT NULL,  
  `vc_mail`  varchar(20) NOT NULL,  
  `vc_date`  date ,
  PRIMARY KEY (`vc_no`)  
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;  


 */


@Entity(name = "Tstudent")
public class Student {


    @Column(name = "vc_no")
    private String  No ;

    @Column(name = "vc_name")
    private String  Name ;

    @Column(name = "vc_sex")
    private String  Sex  ;

    @Column(name = "vc_profession")    
    private String  Profession ;

    @Column(name = "vc_tel")
    private String  Tel ;

    @Column(name = "vc_mail")
    private String  Mailbox ;

    @Column(name = "vc_date")
    private String  Date ;

    @Column(name = "vc_education")
    private String  Education  ;

    @Column(name = "vc_schoolyear")
    private String  Schoolyear  ;

    public String getNo() {
        return No;
    }

    public void setNo(String no) {
        No = no;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getSex() {
        return Sex;
    }

    public void setSex(String sex) {
        Sex = sex;
    }

    public String getProfession() {
        return Profession;
    }

    public void setProfession(String profession) {
        Profession = profession;
    }

    public String getTel() {
        return Tel;
    }

    public void setTel(String tel) {
        Tel = tel;
    }

    public String getMailbox() {
        return Mailbox;
    }

    public void setMailbox(String mailbox) {
        Mailbox = mailbox;
    }

    public String getDate() {
        return Date;
    }

    public void setDate(String date) {
        Date = date;
    }

    public String getEducation() {
        return Education;
    }

    public void setEducation(String education) {
        Education = education;
    }

    public String getSchoolyear() {
        return Schoolyear;
    }

    public void setSchoolyear(String schoolyear) {
        Schoolyear = schoolyear;
    }

    @Override
    public String toString() {
        // TODO Auto-generated method stub
            return JSONObject.toJSONString(this) ;
    }

}
package com.liyang.table;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.liyang.database.DbRunner;



@Service
public class BusinessService {

        @Autowired
        @Qualifier("springJdbcDbRunner")
        private DbRunner dbRunner;


        public void  addStudent(Student stu){
              if(stu != null)
                   dbRunner.insert(stu) ;
        }

        public void  updateStudent(Student stu ){
              if(stu != null)
                   dbRunner.insert(stu) ;
        }

        public List<Student> getStudent(String sno){
              return  dbRunner.find(Student.class ,
                            "select * from Tstudent where vc_no = ? ", sno) ;
        }

        public void  addteam(Team team){
              if(team != null)
                   dbRunner.insert(team) ;
        }

        public List<Team> getTeam(String teamname){
              return  dbRunner.find(Team.class ,
                            "select * from Tteam where vc_teamname = ? ", teamname) ;
        }

        public List<Team> getMyTeam(String sno){
               List<Team> teams =   dbRunner.find(Team.class , "select * from Tteam") ;

               List<Team> myteams = new ArrayList<Team>() ;
               for(Team team : teams){
                     if(team.getStuNo1().equals(sno) 
                        || team.getStuNo2().equals(sno) 
                        || team.getStuNo3().equals(sno) ){
                        myteams.add(team) ; 
                     }
               }

               return myteams ;
        }

}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

DB2入门(1)--安装、启动、连接

1.安装数据库windows下的安装软件下载直接是从官网下载的, 下载免费试用版学习一下: 1. 进入官网,点击“Free DB2 trials” 2. 然后选择自己要下载的版本,我选择的是社...

openstack ice自定义调度算法项目详解(horizon、novaclient、api、scheduler、db、自定义数据库)

原文转自:openstack ice自定义调度算法项目详解(horizon、novaclient、api、scheduler、db、自定义数据库) 第一部分:页面层即horizon与novaclien...

DB2创建用户及赋予权限

DB2-创建用户和组,数据库 1、增加一个操作系统用户  groupadd test---添加用户组test  useradd -m -g test -d /home/test test--...

weblogic 的应用 常见问题处理 db2 链接不上

xingkaistart   weblogic10之Failed to initialize the application 'wss-1-1' due to error weblogic...

db2创建用户及授权的研究

1、创建系统用户dbuser/ehong隶属于db2users    2、C:\Program Files\IBM\SQLLIB\BIN>db2 connect to AKZXTEST 数据库连...

YII2-数据库yii\db\Query 查询方法

yii\db\Query 查询方法 A typical usage of the query builder looks like the following: $rows = (new \yii...
  • xmlife
  • xmlife
  • 2015年06月12日 14:56
  • 3419

ora-01261:参数db_recovery_file_dest的目标字符串无法被翻译

本地WINDOWS数据库登陆的时候,无端报出ORA-01261错误,描述如下图 之前也遇到过这样的情况,然后翻看之前的邮件发现解决方法很简单。 从下面的错误信息可知 ora-01261:Para...
  • scogeek
  • scogeek
  • 2013年01月20日 15:00
  • 4148

Berkeley DB基础教程

一、Berkeley DB的介绍 (1)Berkeley DB是一个嵌入式数据库,它适合于管理海量的、简单的数据。如Google使用其来保存账户信息,Heritrix用其来保存froniter. (...

DB2的License失效引发的问题及解决办法

今天在启动DB2时,遇到了下列情况: db2@linux:/opt/ibm/db2/V9.7/bin> db2start  03/31/2012 10:33:23     0   0   SQL8...
  • lyjwin
  • lyjwin
  • 2012年03月31日 14:41
  • 4884

Java连接db2数据库(常用数据库连接五)

1.安装好db2数据库,并建立表如下: 2.eclipse或myeclipse中建立工程并导入java连接db2所需要的jar包db2java.jar 下载地址:http://download.c...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:db
举报原因:
原因补充:

(最多只允许输入30个字)