473,395 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem regarding JDBC

package com.trewport.orderprocess.action;

import java.io.*;
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.lang.Object;
import javax.servlet.*;
import javax.servlet.http.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import com.trewport.orderprocess.form.EditForm;
import com.trewport.orderprocess.model.EditModel;

public class EditAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception,SQLException
{

EditForm editForm=(EditForm)form;
PrintWriter out=response.getWriter();
String orderNo = editForm.getOrderNo();
String orderName = editForm.getOrderName();
String orderQuantity = editForm.getOrderQuantity();
String orderBillingDate = editForm.getOrderBillingDate();
int orderAmount = editForm.getOrderAmount();
int totalSum = editForm.getTotalSum();
String userId = editForm.getUserId();
String date= editForm.getDate();

ActionErrors errors =new ActionErrors();

PrintWriter pw=response.getWriter();

/* this is setting up of Session */
HttpSession session = request.getSession(true);
String id= session.getAttribute("user").toString();
String dat= session.getAttribute("date").toString();
String pol= session.getAttribute("orno").toString();

System.out.println(""+pol);
Connection con=null;
PreparedStatement stmt=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:pop");
String str="update ord set orderNo=?, "+
"orderName=?, "+
"orderQuantity=?, "+
"orderBillingDate=?, "+
"orderAmount=?, "+
"totalSum=?, "+
"userId=?, "+
"date=? "+
"where orderNo=? ";

stmt=con.prepareStatement(str);

stmt.setString(1,orderNo);
stmt.setString(2,orderName);
stmt.setString(3,orderQuantity);
stmt.setString(4,orderBillingDate);
stmt.setInt(5,orderAmount);
stmt.setInt(6,totalSum);
stmt.setString(7,id);
stmt.setString(8,dat);
stmt.setString(9,pol);

int x=stmt.executeUpdate();


EditModel em = new EditModel();
em.setOrderNo(orderNo);
em.setOrderName(orderName);
em.setOrderQuantity(orderQuantity);
em.setOrderBillingDate(orderBillingDate);
em.setOrderAmount(orderAmount);
em.setTotalSum(totalSum);
em.setUserId(userId);
em.setDate(date);
em.saveToPersistentStore();
System.out.println("the record has been entered"+x);
return (mapping.findForward("success"));
}catch(Exception ee)
{
System.out.println("43 ----");
ee.printStackTrace();
}
finally
{
stmt.close();
con.close();
}
return (mapping.findForward("failure"));
}
}

for the update statement in my program its is giving this error
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in
UPDATE statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:31 50)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Jd bcOdbcPreparedState
ment.java:214)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(JdbcOdbcPrepare
dStatement.java:136)
at com.trewport.orderprocess.action.EditAction.execut e(EditAction.java:8
0)
at org.apache.struts.chain.commands.servlet.ExecuteAc tion.execute(Execut
eAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAc tion.execute(Abstra
ctExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase .execute(ActionComm
andBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.exe cute(LookupCommand.
java:304)
at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor .process(Composable
RequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:191
3)

My Bsaic program is
Jan 28 '08 #1
1 1866
r035198x
13,262 8TB
1.) Please use code tags when posting code.
2.) An easy way to debug these problems is to System.out.println the sql statement before it gets executed.
Jan 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
10
by: sssk28 | last post by:
i have installed fedora core 6 and i am getting following error: type Exception report message description The server encountered an internal error () that prevented it from fulfilling this...
1
by: vasilip | last post by:
Can anyone help me out with these two issues I seem to be having? using the db2 driver for PHP (db2_xxxxxx) functions 1. If I forget, or for some reason db2_commit/db2_rollback doesn't get...
0
by: swathi123 | last post by:
hi all here im trying to create .csv file. my code is public class CSVFile { public static void main(String args) { String record=null; try {
1
by: swathi123 | last post by:
hi all here im trying to create .csv file. my code is public class CSVFile { public static void main(String args) { String record=null; try {
5
by: pradeep84 | last post by:
hi..to all........ i used the following code... in order to check the input with the database... but i had a error java.sql.SQLException: No data found i checked the database name... and database...
2
by: shivapadma | last post by:
The following is the front end code for searching , it takes data and searches from the database by the second code. FRONT END CODE: <html> <head> <meta http-equiv="Content-Language"...
2
by: shivapadma | last post by:
i have inserted the image into database using the following code String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/"; String dbName =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.