I have a difficaulty with LIKE operator
This is my code, where i want to use LIKE operator to recieve a specific string. But somehow, i get an sql exception.



    public synchronized void sendNames() {
        	final ArrayList<String> drinkar = new ArrayList<String>();
			
  		  Connection con = null;
  		  String url = "jdbc:mysql://localhost:3306/";
  		  String db = "drycker";
  		  String driver = "com.mysql.jdbc.Driver";
  		  String user = "root";
  		  String pass = "";
  		  
  		  try{
  			    Class.forName(driver).newInstance();
  			    con = DriverManager.getConnection(url+db, user, pass);
  			  try{
  			    Statement st = (Statement) con.createStatement();
  			    String SQL = "SELECT * FROM  drinkar WHERE Namn LIKE 'A%'";
  			    ResultSet res = st.executeQuery(SQL);
  			  while (res.next()) {
  			    String s = res.getString(SQL);
  			    drinkar.add(s);
  			  }
  			  System.out.println(drinkar);
  			    con.close();
  			  }
  			  catch (SQLException s){
  			    System.out.println("SQL code does not execute.");
  			  }  
  			  }
  			  catch (Exception e){
  			    e.printStackTrace();
  			  }
       
        
        try {
            oos.writeObject(drinkar);
            oos.close();
        } catch (Exception e) {
        	System.out.println(e);
        }

 Also i dont know if i am printing it correctly. Since i try to print String SQL, which has not been executed.
I have a difficaulty with LIKE operator
===

This is my code, where i want to use LIKE operator to recieve a specific string. But somehow, i get an sql exception.



    public synchronized void sendNames() {
        	final ArrayList<String> drinkar = new ArrayList<String>();
			
  		  Connection con = null;
  		  String url = "jdbc:mysql://localhost:3306/";
  		  String db = "drycker";
  		  String driver = "com.mysql.jdbc.Driver";
  		  String user = "root";
  		  String pass = "";
  		  
  		  try{
  			    Class.forName(driver).newInstance();
  			    con = DriverManager.getConnection(url+db, user, pass);
  			  try{
  			    Statement st = (Statement) con.createStatement();
  			    String SQL = "SELECT * FROM  drinkar WHERE Namn LIKE 'A%'";
  			    ResultSet res = st.executeQuery(SQL);
  			  while (res.next()) {
  			    String s = res.getString(SQL);
  			    drinkar.add(s);
  			  }
  			  System.out.println(drinkar);
  			    con.close();
  			  }
  			  catch (SQLException s){
  			    System.out.println("SQL code does not execute.");
  			  }  
  			  }
  			  catch (Exception e){
  			    e.printStackTrace();
  			  }
       
        
        try {
            oos.writeObject(drinkar);
            oos.close();
        } catch (Exception e) {
        	System.out.println(e);
        }

 Also i dont know if i am printing it correctly. Since i try to print String SQL, which has not been executed.