Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-28-2012, 10:42 AM   PM User | #1
shunaqie_89
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 6
Thanked 0 Times in 0 Posts
shunaqie_89 is an unknown quantity at this point
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..
shunaqie_89 is offline   Reply With Quote
Old 09-29-2012, 05:55 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 09-30-2012, 04:41 PM   PM User | #3
Trollypolly
New to the CF scene

 
Join Date: Sep 2012
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Trollypolly is an unknown quantity at this point
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.
Trollypolly is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:38 PM.


Advertisement
Log in to turn off these ads.