发表于: 2017-02-24 22:44:42

4 1580


今天完成的事:

1.了解了Java的继承性,即关于extends关键词的使用;其用途主要用于编写子类和继承接口。

2.浏览了spring的大概框架,对spring有了个初步的概念;

3.粗略看了下JDBC的构造,了解了搭建JDBC的方法,类体具体如下:

  1. public class ConnectToDataBase {  
  2.     public static Connection getDataBaseConnection(){  
  3.         String driver="com.mysql.jdbc.Driver";  
  4.         String url="jdbc:mysql://localhost:3306/db_pms";  
  5.         String user="root";  //用户名
  6.         String password="******";  //密码
  7.           
  8.         //加载驱动程序  
  9.         try {  
  10.             Class.forName(driver);   
  11.         } catch (ClassNotFoundException e) {  
  12.             e.printStackTrace();  
  13.         }    

  14.         //链接数据库
  15.         Connection conn=null;
  16.         try {
  17.         conn=DriverManager.getConnection(url, user, password);
  18.         if (!conn.isClosed()) {
  19.                 System.out.println("Connected");
  20.             }
  21.         } catch (SQLException e) {
  22.             System.out.println("Disconnected: "+e.getMessage());
  23.         }
  24.         return conn;       
  25.   }

遇到的问题:

在classpath中设置环境变量加载驱动失败了,求问驱动包的位置在java build path中来手动载入;

明天的计划:

1.继续学习spring,了解DAO的架构;

2.尝试理解和修改.xml。


返回列表 返回列表
评论

    分享到