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("删除完毕");

    }
    }

  • 相关阅读:
    汇编笔记
    C++知识点复习
    flask 初步
    flask and postgre on heroku
    google zxing二维码库 初始
    flasklogin解读
    flasksqlalchemy 关系(一对多)
    flask的信号
    flask 范例学习
    github 操作纪录
  • 原文地址:https://www.cnblogs.com/simly/p/11547937.html
Copyright © 2011-2022 走看看