Day01_JDBC

  • ALT+SHIFT+L
自动生成返回值对象,光标放在语句前面或者后面。
  • Public static 和 Public区别
public static 表示公共的静态方法;
public 表示公共的方法;
静态方法不需要实例化,直接通过 类名.方法()掉问;
公共方法需要实例化,通过new 类名.方法()调用;
  • JDBC工具类
1、使用静态块配置信息如Driver,username,password
2、注册驱动并获取连接
3、释放资源
  • 使用properties对象
1、加载properties获得流
2、创建properties对象
3、使用properties对象加载流。
  • JDBC增改删查
    增加:
insert into 表名(参数1,参数2) values(值1,值2);

修改:

update 表名 set xx=yy where 条件;

删除:

delete from 表名 where 条件;

查询:

Select * from 表名 where 条件;
返回结果为ResultSet,使用rs.getString("UID")或者rs.getString(1);
使用rs.next()判断是否还存在内容!

你可能感兴趣的:(Day01_JDBC)