zoukankan      html  css  js  c++  java
  • mysql数据库连接标准操作

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

    public class DataBaseConnection {  private static final String DBDRIVER = "org.gjt.mm.mysql.Driver" ;  private static final String DBURL = "jdbc:mysql://localhost:3306/mldn" ;  private static final String DBUSER = "root" ;  private static final String DBPASS = "mysqladmin" ;  private Connection conn = null ;  public DataBaseConnection(){   try {    Class.forName(DBDRIVER) ;   } catch (ClassNotFoundException e) {    // TODO Auto-generated catch block    e.printStackTrace();   }   try {    conn = DriverManager.getConnection(DBURL, DBUSER,DBPASS) ;   } catch (SQLException e) {    // TODO Auto-generated catch block    e.printStackTrace();   }  }  public Connection getConnection(){   return this.conn ;  }  public void close(){   if(this.conn!=null){    try {     this.conn.close() ;    } catch (SQLException e) {     // TODO Auto-generated catch block     e.printStackTrace();    }   }  } }

  • 相关阅读:
    基本HAL库操作函数整理
    oled(iic协议)
    Uart串口中断收发
    博主回来啦
    博主的冒泡1
    AFO

    起床困难综合症
    费解的开关
    数独
  • 原文地址:https://www.cnblogs.com/6502ck/p/3391266.html
Copyright © 2011-2022 走看看