zoukankan      html  css  js  c++  java
  • java 21-connetmysql

    package com.inco.hive.lytest;

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

    public class connet_mysql {
    public static void main(String[] args) {
    connet_mysql connet=new connet_mysql();
    try {
    connet.createsql();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public Connection getConnection(){
    Connection connection=null;
    try {
    //加载驱动
    Class.forName("com.mysql.jdbc.Driver");
    //数据库连接url
    String url="jdbc:mysql://localhost:3306/bigdata";
    String user="root";
    String password="123456";
    connection= DriverManager.getConnection(url,user,password);
    }
    catch (Exception ee){
    ee.printStackTrace();
    }
    return connection;
    }
    public void createsql() throws Exception {
    Connection con = getConnection();
    Statement st=con.createStatement();
    st.execute("delete from mytableV where id=2");
    st.close();
    System.out.println("删除完毕");

    }
    }

  • 相关阅读:
    Redis主从复制
    POI导出给指定单元格添加背景色
    Mybatis的resultMap使用
    前后端分离
    日常总结
    java环境变量配置
    Java线程池七个参数详解
    java中常见的锁
    Linux定时任务
    SQL语句的整理
  • 原文地址:https://www.cnblogs.com/simly/p/11547937.html
Copyright © 2011-2022 走看看