发表于: 2017-02-27 00:22:35

4 1598


今天完成的事情完成了数据库接口层的 1模型创建2.方法接口

                      
明天计划的事情:    方法实现类impl层

                       
遇到的问题:      1.,为什么ID自增就不需要set步骤了?

                          

                             2.如何导入大量的数据。。。比如几百万条。。

                           3.构造方法和主方法括号内的参数不太理解,还需要多看。

                  
收获:1.数据模型的建立。除开自增的ID,其他数据均有两步,先从数据库提取进入内存这一步称之为set,再从内存赋值称之为get。

2.方法接口














2017.2.27

今天完成的事情: 1.租了一个云服务器。2, 调试dao实现类,很懵逼。                     
明天计划的事情:  学习Junit                 
遇到的问题:    实现类中,方法重复出现。                        

package com.jnshu.dbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public   class DatebaseStudentMethodImpl implements DatebaseStudentMethod {
 public long insert(Student c) {
  String sql = "insert into Student(Name,Qq,Type,School,Wish,Introducer)values(?,?,?,?,?,?)";
  Connection conn =DatebaseConnection.open(null);
  try {
   PreparedStatement pstmt = conn.prepareStatement(sql);
   pstmt.setString(1, c.getName());
   pstmt.setLong(2, c.getQq());
   pstmt.setString(3, c.getType());
   pstmt.setString(4, c.getSchool());
   pstmt.setString(5, c.getWish());
   pstmt.setString(6, c.getIntroducer());
   pstmt.executeUpdate();
  } catch (SQLException e) {
   e.printStackTrace();
  }finally {
   DatebaseConnection.close();
  }
  return c.getId();
 }
 public void Update(Student c) {
  String sql = "update student set Name=?,Qq=? ,Type=?,School=?,Wish=?,Introducer=?where id = ?";
  Connection conn = DatebaseConnection.open(null);
  try {
   PreparedStatement pstmt = conn.prepareStatement(sql);
   pstmt.setString(1, c.getName());
   pstmt.setLong(2, c.getQq());
   pstmt.setLong(3,  c.getId());
   pstmt.setString(4, c.getType());
   pstmt.setString(5, c.getType());
   pstmt.setString(6, c.getType());
   pstmt.setLong(7, c.getId());
   pstmt.executeUpdate();
  } catch (SQLException e) {
   e.printStackTrace();
  }finally {
   DatebaseConnection.close();
  }
 }
 public Student GetStudentByid(long id) {
  // TODO Auto-generated method stub
  return null;
 }
 public void Delete(long id) {
  // TODO Auto-generated method stub  
 }
 public long Insert(Student c) {
  // TODO Auto-generated method stub
  return c.getId()+1;

 }
}

4.红色的部分会自动强行生成,在实现类中命名前面已经有了insert方法的实现,为什么最后还要加一个insert?(如果没有,会提示编码错误)
收获:1.大小写会导致指代不明,程序无法识别类或者包。

           2.熟悉构造方法的调用



返回列表 返回列表
评论

    分享到