zoukankan      html  css  js  c++  java
  • Spring对jdbc的支持学习笔记

    1. 非加连预执释方式

    2. dataSource对jdbc的支持

        DataSource对象

      ====》JdbcTemplate jdbcTemplate

      ====》String sql = "INSERT INTO product (product_name,sale_price) VALUES (?,?)";

     ====》this.jdbcTemplate.update(sql,product.getProductName(),product.getSalePrice());

    3. 一般的连接池使用:
         Connection connection = basicDataSource.getConnection() ;

          String sql="INSERT INTO product (product_name,sale_price) VALUES (?,?)";
          PreparedStatement preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1,product.getProductName());
    preparedStatement.setInt(2,product.getSalePrice());
    preparedStatement.executeUpdate();
    preparedStatement.close();
    4. 原始的jdbc:

    // 加
            try {
    Class.forName("com.mysql.jdbc.Driver") ;
    // 连
    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/station_demo", "root", "root");
    // 译
    Statement statement = connection.createStatement();
    // 执
    // String sql = "INSERT INTO product (product_name, sale_price) VALUES ('小来手机', 555)" ;
    String sql = "INSERT INTO product (product_name, sale_price) VALUES ('" + productName + "'," + salePrice + ")" ;
    statement.executeUpdate(sql) ;
    // 释
    statement.close();
    connection.close();
    逆天改命!我命由我不由天!
  • 相关阅读:
    LoaRunner性能测试系统学习教程:日志文件分析(8)
    LoaRunner性能测试系统学习教程:MPM相关参数(7)
    LoaRunner性能测试系统学习教程:MPM调优(6)
    响应器
    分页器
    权限组件、频率组件
    drf视图组件、认证组件
    drf序列化组件
    RESTful
    IO操作、PIL使用、Django的admin操作
  • 原文地址:https://www.cnblogs.com/huhewei/p/13890081.html
Copyright © 2011-2022 走看看