private static final String CLASS = "com.mysql.jdbc.Driver"; //驱动类 private static final String DRIVER = "jdbc:mysql://localhost:3306/SHIOT"; //驱动 private static final String USERNAME = "root"; //数据库用户名 private static final String PWD = "root"; //数据库密码 private static Connection conn = null; private static PreparedStatement stmt=null; private static ResultSet rs = null; public Connection getCon() { try { Class.forName(CLASS); conn = DriverManager.getConnection(DRIVER,USERNAME,PWD); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return conn;
}