Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:47:30+00:00 2026-06-12T13:47:30+00:00

I’m trying to find this mistake: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL

  • 0

I’m trying to find this mistake:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ‘% ORDER BY
t1.nombre_cuenta ASC’ at line 1

Where is it?. Thanks so much:

public Tdatoscuentas[] consultarCuentas(int id_tipo_cuenta){  //Acabar método para login

    Tdatoscuentas[] params = null; 

    try {
        this.conexion=conectar();
        System.out.println("Vamos a usar el id tipo cuenta:"+id_tipo_cuenta);
        int id_tipo_cuenta_padre=id_tipo_cuenta-1;
        //System.out.println();

        SQL="SELECT t1.id_cuenta as id_cuenta,"+     
                "t1.n_cuenta as n_cuenta,"+
           "SUBSTRING_INDEX(t1.n_cuenta,'.',"+id_tipo_cuenta_padre+") as n_cuenta_padre,"+
           "t1.nombre_cuenta as nombre,"+         
           "(SELECT tt1.cif"+
           "  FROM cuentas_rs tt1"+
            " WHERE tt1.id_cuenta = t1.id_cuenta"+
            " ORDER BY tt1.f_inicio DESC "+
            " LIMIT 1) as cif,"+                          
            "(SELECT tt2.porcentaje "+
            " FROM impuestos tt2"+
            " WHERE tt2.id_pais = (SELECT tt1.cif"+
            "                     FROM cuentas_rs tt1"+
            "                     WHERE tt1.id_cuenta = t1.id_cuenta"+
            "                     ORDER BY tt1.f_inicio DESC"+
            "                     LIMIT 1)"+
            " ORDER BY tt2.f_inicio DESC "+
            "LIMIT 1)  as impuesto,"+
           "t1.descuento as descuento,"+      
           "t1.id_tipo_cuenta as nivel,"+          
           "t1.borrado  as borrado,"+        
           "t1.cod_cliente as cod_cliente "+     
           "FROM cuentas t1 "+
           "LEFT OUTER JOIN cuentas_rs t2 ON t2.id_cuenta = t1.id_cuenta"+ 
           " WHERE t1.id_esquema_asociado = 1"+  
           " AND t1.id_proveedor_cloud = 1"+
           " AND SUBSTRING(t1.n_cuenta,1,LENGTH(001.00001))"+
           " AND t1.id_tipo_cuenta =("+id_tipo_cuenta+")"+
           " AND t1.borrado = false"+         
           " AND t1.nombre_cuenta LIKE %" +         
           " ORDER BY t1.nombre_cuenta ASC";

        System.out.println("La consulta de SQL para consultar Cuentas es:"+SQL);
        this.pstm     = this.conexion.prepareStatement(SQL);

        this.rs =  pstm.executeQuery();

        this.rs.last(); 
        int numRows = this.rs.getRow(); 
        this.rs.beforeFirst();
        System.out.println("Vamos a hacer:"+numRows);
        params = new Tdatoscuentas[numRows];

        int i=0;
         while(this.rs.next()){
             params[i] = new Tdatoscuentas();
                params[i].setId_cuenta(this.rs.getInt("id_cuenta"));
                params[i].setN_cuenta(this.rs.getString("n_cuenta"));
                params[i].setN_cuenta_padre(this.rs.getString("n_cuenta_padre"));
                params[i].setNombre_cuenta(this.rs.getString("nombre"));
                params[i].setCif(this.rs.getString("cif"));
                params[i].setImpuesto(this.rs.getDouble("impuesto"));
                params[i].setDescuento(this.rs.getDouble("descuento"));
                params[i].setNivel(this.rs.getInt("nivel"));
                params[i].setBorrado(this.rs.getBoolean("borrado"));
                params[i].setCod_cliente(this.rs.getString("cod_cliente"));

            i++;        

            }
         System.out.println("params tiene una long de"+params.length);
         return params;  
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return params;  

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:47:31+00:00Added an answer on June 12, 2026 at 1:47 pm

    Take a look at the documentation on pattern matching.

    Change

    ” AND t1.nombre_cuenta LIKE %” +

    into

    ” AND t1.nombre_cuenta LIKE ‘%'” +

    I also second @podiluska’s suggestion to look into using bind variables in your queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.