Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    6
    Thanked 0 Times in 0 Posts

    java.sql.SQLException: Could not set SQL query

    Hi,

    I have a problem wit setSQL.
    My coding like below,

    PHP Code:
    try {
                        
    sql "SELECT " COLUMN_1 COLUMN_2 COLUMN_3 COLUMN_4;
                        
    sql2 " FROM " PARAM_TABLE " ORDER BY " COLUMN_1 COLUMN_2;

                        
    sqlUtil.setSQL(sql+sql2);

                        
    DefaultLogger.debug(this'\n'+"SQL String-> " sql +'\n'sql2);
                }
                catch (
    SQLException e) {
                    
    e.printStackTrace();
                throw new 
    SQLException("Could not set SQL query");
                } 


    and get error like below,
    Code:
    Exception = 
    java.sql.SQLException: Could not set SQL query
    	at com.bkr.retail.app.common.ParamDAO.getParameterList(ParamDAO.java:66)
    	at com.bkr.retail.ui.common.ParamManager.getParameterData(ParamManager.java:43)
    	at com.bkr.retail.ui.common.ParamManager.<init>(ParamManager.java:29)
    	at com.bkr.retail.ui.common.ParamHelper.getInstance(ParamHelper.java:22)
    	at com.bkr.retail.ui.financing.FinancingEligibilityCheckPersonalLoanFormValidator.validateInput(FinancingEligibilityCheckPersonalLoanFormValidator.java:110)
    	at com.bkr.retail.ui.financing.FinancingEligibilityCheckPersonalLoanAction.validateInput(FinancingEligibilityCheckPersonalLoanAction.java:167)
    	at com.bkr.retail.ui.common.framework.CommonAction.perform(CommonAction.java:260)
    	at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1720)
    	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1519)
    	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:505)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    	at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
    	at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
    	at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
    	at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6722)
    	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    	at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
    	at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
    	at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
    	at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

    Can anyone help me with this problem? Really have no idea why.
    I'm using j2sdk1.4.2_05..

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    There's simply not enough information here. What does the sqlUtil.setSql do?
    You should move the DefaultLogger call up as well; if the sqlUtil tosses the exception (which it appears to), the logger cannot issue a .debug call since it will never make it there. But knowing what that sql string it created is would be handy.

  • #3
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    If you are trying to pull information from your database there are a couple of ways of doing this. You can do:

    Code:
    String sql = "SELECT " + select +
                 		" FROM " + from +
                 		" JOIN " + join +
                 		" ON " + on1 + " = " + on2 +
                 		" WHERE " + where +
                        " ORDER BY " + order;
                 
                 Cursor mCur = mDb.rawQuery(sql, null);
    You can add/remove any SQL commands from my code and it should work. You will be returned a cursor which you will need to know how to gather information from aswell.

    Another way of pulling information from your database is:

    Code:
    String table = "insertTableNameHere";  //Table name goes here
    String[] = {"column1", "column2"}  //any columns you need to put, place here.
    
    Cursor cursor = mDb.query(tableName, column, null, null, null, null, null);
    If you have any questions feel free to ask.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •