首页 > 其他分享 >JDBC--API--Statement

JDBC--API--Statement

时间:2023-04-21 17:35:51浏览次数:40  
标签:JDBC java String -- Statement sql import conn

  1. import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;

    public class jdbcdemo_Statement {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://127.0.0.1:3306/homework?useSSL=false";
    String user="root";
    String password="1234";
    Connection conn = DriverManager.getConnection(url, user, password);
    String sql="update lyj set credit=888 where id=3";
    Statement statement = conn.createStatement();
    conn.setAutoCommit(false);
    try {

    int i = statement.executeUpdate(sql);
    if (i>0){
    System.out.println("执行成功");
    }else {
    System.out.println("执行失败");

    } } catch (SQLException throwables) {
    conn.rollback();
    throwables.printStackTrace();
    }
    conn.commit();

    conn.close();
    statement.close();


    }
    }

     

标签:JDBC,java,String,--,Statement,sql,import,conn
From: https://www.cnblogs.com/lyjzht/p/17341169.html

相关文章

  • 使用PhantomJS解决VUE项目无法被百度收录
    一、安装PhantomJS安装文章:https://www.cnblogs.com/robots2/p/17340143.html二、编写脚本spider.js//spider.js'usestrict';console.log('=====start=====');//单个资源等待时间,避免资源加载后还需要加载其他资源varresourceWait=500;varresourceWaitTimer;/......
  • Spring cloud:开发接口
    @RequestBody支持json格式,前端传过来某类型的数据,后端直接可以用@RequestParam?id=1此类传参,有时候会导致类型不能转换错误例如,前端页面分页,传过来的page、size,在地址栏显示,路径后?id=xx ,两个数据明显是int,如果用了@RequestParam接收多个参数后端以Map接收,不能直接接收,且报类型......
  • 数据流图(刷题)
         ......
  • spring boot、cloud -yml:显示/show SQL
    logging:level:com.zking.zkingOAS.FDadmin.mapper:debug在控制台显示业务具体执行的SQL,且有参数说明、有多少数据 application.properties:logging.level.com.wochat.mapper=debug ......
  • CSS 基础拾遗(核心知识、常见需求)
    本篇文章围绕了CSS的核心知识点和项目中常见的需求来展开。虽然行文偏长,但较基础,适合初级中级前端阅读,阅读的时候请适当跳过已经掌握的部分。这篇文章断断续续写了比较久,也参考了许多优秀的文章,但或许文章里还是存在不好或不对的地方,请多多指教,可以评论里直接提出来哈。核心......
  • mybatis-plus-方法
    /***Copyright(c)2011-2016,hubin([email protected]).*<p>*LicensedundertheApacheLicense,Version2.0(the"License");youmaynot*usethisfileexceptincompliancewiththeLicense.Youmayobtainacopyof*theLicenseat......
  • 远程办公软件哪个好?远程办公软件推荐
    远程办公软件哪个好?自从yq爆发以来,远程办公成为了人们生活中不可或缺的一部分。随着yq的加剧,越来越多的公司开始尝试远程办公。为此,远程办公软件的需求也急剧上升。但是,远程办公软件市场如此广泛和复杂,它们中的许多都有类似的功能和服务。那么,远程办公软件哪个好呢?本文将介绍一些......
  • redis:清空 spring boot注解式
    flushall清空打开D:\ProgramFiles\Java\Redis-x64-3.2.100\redis-cli.exeauth123456flushall  dockerdockerexec-it65e343434e6eredis-cliauth123flushall exit @Cacheable :根据方法的请求参数对其结果进行缓存参数解释examplevalue缓存的名称,在spring配置文......
  • 推荐一些好用软件吧
    音乐播放器洛雪音乐一个开源的音乐播放器,全平台支持。且不用登陆,也不用会员https://github.com/lyswhut茂茂音乐播放器一个96年的小朋友做的开源的音乐播放平添,不过都是网页版本的。如果你的设备低配,或者不想安装客户端,不妨一试。https://github.com/maomao1996其它太......
  • 怎么打开etl文件
    ctrl+R输入perfmon后回车C:\Users\zhang>cd/dC:\Windows\System32\LogFiles\WMIC:\Windows\System32\LogFiles\WMI>tracerpt.exeNtfsLog.etl-lr-o123.xml-ofXML......