Jump to content

JSP = Variable doesn't pull the correct data from Access. HELP!!

- - - - -

  • Please log in to reply
No replies to this topic

#1
ascil85

ascil85

    Newbie

  • Members
  • Pip
  • 1 posts
Hi:crying:, I've got a headache with this. I'm not really good at it.

- My DB = MS Access.
- I need to pull out the specific project_goal from the table .
- I've executted SQL in access, it shows perfect data. But it doesn't with my .jsp. It always shows 0%

My input page are all drop down lists. Here goes.

Connection con9 =null;
Statement st9=null;
ResultSet res9=null;
//getting the input from input page
projectID = request.getParameter("proID");
stressID = request.getParameter("stressID");
passnumber = request.getParameter("passnum");
hidprojname = request.getParameter("hidprojname1");
orgvalue = request.getParameter("orgvalue");

<%


//retrieve list of project from ms access
double man_goal=0.0, indi_goal_today=0.0;
String passnumber_str = "", passnumber_get="";

if(!passnumber.equals("ALL"))
{
passnumber_str = request.getParameter("passnum");
}


String mangoalquery =" SELECT project_goal.indi_goal_today FROM project_goal WHERE ("+passnumber_str+"((project_goal.project_id)="+projectID+") AND((project_goal.date)=#"+sdf.format(cal.getTime())+"#)) GROUP BY project_goal.indi_goal_today" ;
System.out.println("mangoalquery = "+mangoalquery);

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "c:/test.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
con9 = DriverManager.getConnection( database ,"","");
st9 = con9.createStatement();
res9 = st9.executeQuery(mangoalquery);

if (res9 != null)
{
while (res9.next())
{
man_goal= res9.getDouble("indi_goal_today")// DB column which the expected value to be returned;

System.out.println("man_goal"+man_goal);

}
}


else
{
man_goal = 100; // I'd like to put all values to 100% if it's not the value from SQL
}

}


catch (Exception e)
{
System.out.println("Error: " + e);
}

con9.close();
%>


Would really appreciate it if some one could tell me what i've done wrong with the query. Why it isn't returning the value executed in SQL. And why it isn't showing 100% even though the value is not of expected ones.

Need your intelligence in this~~Appreciate it :crying::crying::crying::crying:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users