jdbc
JDBCUtlis工具类
其实就是将,java连接mysql的方法进行封装,使得重复代码减少
连接和关闭都算是重复代码。
public class JDBCUtils { public static Connection getConnect() throws IOException, ClassNotFoundException, SQLException { //导入配置信息 Properties properties = new Properties(); properties.load(new FileInputStream("D:\\IDEA\\workspace\\mysql.properties")); String driver = properties.getProperty("driver"); String url = properties.getProperty("url"); String user = properties.getProperty("user"); String password = properties.getProperty("password"); Class.forName(driver); Connection connection = DriverManager.getConnection(url, user, password); return connection; } public static void closeConnect(ResultSet resultSet, Statement statement,Connection connection) throws SQLException { if(resultSet != null){ resultSet.close(); } if(statement != null){ statement.close(); } if(connection != null){ connection.close(); } } }
url=jdbc:mysql://localhost:3306/sora?rewriteBatchedStatements=true user=root password=root driver=com.mysql.cj.jdbc.Driver
事务
一个形象的例子就是,当年给人转账时,需要你的账户减少,别人账户增加。不能出现问题,只有一方增加或者减少。事务就是为了解决这样的问题。
批处理
为了提高效率,把一堆sql语句先存在一块。然后提交一堆语句,大概
本文作者:xiaoovo
本文链接:https://www.cnblogs.com/xiaoovo/p/15968084.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步