zoukankan      html  css  js  c++  java
  • 数据库连接代码 (javaBean)

    数据库代码连接

    public class DataCon {
         private static final String Driver = "com.mysql.jdbc.Driver";//jar包驱动
         private static final String url = "jdbc:mysql://localhost:3306/myhome";//数据库连接路径,数据库名
         private static final String user = "root";//数据库用户名
         private static final String password = "root";//数据库密码
            
            
         public Connection getConnction(){
         Connection con = null;
         try {
         Class.forName(Driver);//引用驱动
         con = DriverManager.getConnection(url, user, password);//数据库连接
                    
         } catch (Exception e) {
         e.printStackTrace();
         }
         return con;
         }
        
        
        //关闭数据库
         public void closeAll(ResultSet rs, PreparedStatement ps, Connection con)
         {
         try {
         rs.close();
         ps.close();
         con.close();
         } catch (Exception e) {
         e.printStackTrace();
         }
                
                
         }
    
    }
  • 相关阅读:
    Wiggle Sort II
    Coin Change
    MPLS LDP 知识要点
    MPLS Aggreate & Untag
    Lab MPLS隐藏标签显示
    Lab MPLS过滤标签转发
    MPLS MTU Aggregation
    研究MPLS MTU的问题
    Lab 利用MPLS解决BGP路由黑洞
    MPLS 标签保留
  • 原文地址:https://www.cnblogs.com/Linger-wj/p/3833859.html
Copyright © 2011-2022 走看看