适用于德比的concat的正确语法

时间:2017-01-11 07:27:59

标签: java sql derby

我正在尝试将concat与Derby数据库查询一起使用。但我得到语法错误。如何在Derby中使用concat

以下代码仅供搜索

  public ArrayList <Tablearray>ListUsers(String ValToSearch){
  ArrayList <Tablearray> usersList  = new ArrayList <Tablearray>();
  Statement st;
  ResultSet rs;

  try {
        Connection con = getConnection();
        st = con.createStatement();
        String searchQuery = "SELECT * FROM ABYP WHERE CONCAT(Id_Search, Tyl, Apothkh, Parathrhseis,Ti) LIKE '%"+ValToSearch+"%'";
       //String searchQuery = "SELECT * FROM ABYP WHERE ||CONCAT|| (Id_Search) LIKE '%||"+ValToSearch+"||%'";
        //String searchQuery = "SELECT *FROM ABYP where ID_SEARCH =? ";
        rs = st.executeQuery(searchQuery);
  Tablearray tablearray;
  while (rs.next()){
  tablearray = new Tablearray (
    rs.getString("Id_Search"),
    rs.getString("Tyl"),
    rs.getString("Apothkh"),
    rs.getString("Parathrhseis"),
    rs.getString("Ti")
      );
  usersList.add(tablearray);
  }
  }catch(Exception ex){
        System.out.println(ex.getMessage());
    }

    return usersList;


  }

0 个答案:

没有答案