try { Connection conn = null; Statement stmt = null; ResultSet rs = null; String urlDB = "jdbc:mysql://127.0.0.1:3306/esb?autoReconnect=true&user=root&password=85TIANJIAOyinmi&characterEncoding=utf-8"; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(urlDB); stmt = conn.createStatement(); rs = stmt.executeQuery("select site from esb_commercial where shop='"+shop+"'"); if(rs.next()) { site = rs.getString("site"); } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }