
2024年1月25日大约 108 分钟
JDBC(ava ataase onnectivity)()是java语言操作关系型数据库的一套API
创建工程,导入jar包
注册驱动
Class.forName("com.mysql.jdbc.Driver");
获取连接
String url = "jdbc:mysql://127.0.0.1:3306/jdbc_test";
String username = "root";
String password = "cz";
Connection conn = DriverManager.getConnection(url,username,password);
定义SQL语句
String sql = "update account set money = 2000 where id =1";
获取执行SQL对象
Statement statement = conn.createStatement();
执行SQL
int count = statement.executeUpdate(sql);
处理返回结果
System.out.println(count);
释放资源
statement.close();
conn.close();
是指,所有通过Java语言编写可以通过浏览器访问的程序的总称
是基于请求和响应开发的
getLocalHost()
getByName()
getHostName()
getHostAddress()
public class API_ {
public static void main(String[] args) throws UnknownHostException {
InetAddress localHost = InetAddress.getLocalHost();
System.out.println(localHost);
InetAddress byName = InetAddress.getByName("MaxLifetime-LAPTOP");
System.out.println(byName);
String lh1 = localHost.getHostName();
System.out.println(lh1);
String hm = byName.getHostName();
System.out.println(hm);
}
}
public static 返回值类型 方法名(参数){
方法体
return 0;
}
静态代理是一种设计模式,它可以在不修改原始类的情况下增强其功能。静态代理的好处有以下几点:
例如:
使用黄牛代理,帮我买演唱会门票
1、文件
保存数据的地方
2、 文件流
new File(String pathname)
根据路径创建一个File对象new File(File parent,String chil)
根据父目录文件+子路径构建new File(String parent,String child)
根据父目录+子路径构建