public List<SalesRegisterConfig> getSalesRegisterConfigList() { Connection conn = null; Statement stmt = null; ResultSet rs = null; List<SalesRegisterConfig> resultList = new ArrayList<>(); try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String linkCloudSql = ConfigUtil.pro.get("linkCloudSql").toString();//数据库IP地址 String linkCloudUsername =ConfigUtil.pro.get("linkCloudUsername").toString();//数据库用户名 String linkCloudPassword =ConfigUtil.pro.get("linkCloudPassword").toString();//数据库密码 conn = DriverManager .getConnection( linkCloudSql,linkCloudUsername, linkCloudPassword); stmt = conn.createStatement(); rs = stmt.executeQuery("select vin,* from SalesRegisterConfig where vin is not null and len(vin)=7"); while(rs.next()) { SalesRegisterConfig config = new SalesRegisterConfig(); config.setId(rs.getInt("ID")); config.setCarserialsid(rs.getString("carSerialsID")); config.setCartypeid(rs.getString("carTypeID")); config.setVin(rs.getString("vin")); resultList.add(config); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (!conn.isClosed()) { conn.close(); } if (!stmt.isClosed()) { stmt.close(); } if (!rs.isClosed()) { rs.close(); } } catch (SQLException e) { e.printStackTrace(); } } return resultList; }