473,408 Members | 2,477 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,408 software developers and data experts.

sql statement + java

254 100+
I have this statement in java....

Expand|Select|Wrap|Line Numbers
  1. String str = "update am_msgout set msgout_error ="+errorCode+" where msgout_id ="+cmpTxid;
  2.  
  3. Statement st = connection.createStatement();
  4.  
  5. st.executeUpdate(str);
  6. st.close();
  7.  
  8.  
errorCode = "ASE";
cmpTxid = "63524";


and in the end i get this error :
Expand|Select|Wrap|Line Numbers
  1. com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'ASE' in 'field list'
  2.  
i have try to system print "str" before the call to sql statement....and it give me this:
update am_msgout set msgout_error =ASE where msgout_id =63524

the data i entered is not a column name in database, and it is a value shall be saved into table field.

what's wrong with my sql statement ?
Jul 16 '07 #1
4 1956
r035198x
13,262 8TB
I have this statement in java....

Expand|Select|Wrap|Line Numbers
  1. String str = "update am_msgout set msgout_error ="+errorCode+" where msgout_id ="+cmpTxid;
  2.  
  3. Statement st = connection.createStatement();
  4.  
  5. st.executeUpdate(str);
  6. st.close();
  7.  
  8.  
errorCode = "ASE";
cmpTxid = "63524";


and in the end i get this error :
Expand|Select|Wrap|Line Numbers
  1. com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'ASE' in 'field list'
  2.  
i have try to system print "str" before the call to sql statement....and it give me this:
update am_msgout set msgout_error =ASE where msgout_id =63524

the data i entered is not a column name in database, and it is a value shall be saved into table field.

what's wrong with my sql statement ?
Shouldn't it be
Expand|Select|Wrap|Line Numbers
  1. update am_msgout set msgout_error = "ASE" where msgout_id =63524
i.e. with the quotes?

N.B to put a " in a string in Java you use the \ escape
Jul 16 '07 #2
nickyeng
254 100+
Shouldn't it be
Expand|Select|Wrap|Line Numbers
  1. update am_msgout set msgout_error = "ASE" where msgout_id =63524
i.e. with the quotes?

N.B to put a " in a string in Java you use the \ escape
thanks for the tips...

now it will be like this:
Expand|Select|Wrap|Line Numbers
  1. String str = "UPDATE amsms_msgout SET msgout_error =\""+errorCode+"\" WHERE msgout_id =\""+cmpTxid+"\"";
  2.  
it runs without error but cannot update the table.....

what's wrong now...?
Jul 16 '07 #3
r035198x
13,262 8TB
thanks for the tips...

now it will be like this:
Expand|Select|Wrap|Line Numbers
  1. String str = "UPDATE amsms_msgout SET msgout_error =\""+errorCode+"\" WHERE msgout_id =\""+cmpTxid+"\"";
  2.  
it runs without error but cannot update the table.....

what's wrong now...?
If msgout_id is a number then you do not need to put the quotes around it.
Jul 16 '07 #4
nickyeng
254 100+
thanks again..

it is my mistake that column name in table was different with the one i wrote in the code...

haha..
my mistake

thanks anyway.
:-)
Jul 16 '07 #5

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

Similar topics

3
by: AckbarJedi | last post by:
I'm trying to get a java program to use a GUI included with my textbook, Fundamentals of Java by Lambert and Osborne, called BreezySwing. The book indicates that to import the GUI you need to...
3
by: SOAP | last post by:
how to compile java with assert statement I failed to compile this simple example public class Foo { public void m1( int value ) { assert 0 <= value; System.out.println( "OK" ); }
3
by: Nan Li | last post by:
Hello, all, Does C/C++ ever check the return statement for a non-void function? Look at my simple code below int foo() { } int main()
3
by: Hans-Dieter Franz | last post by:
Hello, I have a problem with a Java user-defined stored procedure and the "alter sequence" statement. I use DB2 8.1.2 and had the same problem with 8.1.0, but not with 7.*. I get the following...
6
by: Doohan W. | last post by:
Hi, I'm now working with DB2, and I can't find out how to execute the contents of a string Statement, without using a Java/... procedure, only using SQL statements. I know that some SQBDs such...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
3
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running...
4
by: robtyketto | last post by:
Greetings, I've got my head spinning with some very simple java coding, Im a newbie to Java and utilising the code below for a javabean for some jsp Im working on. The problem is my code I've...
3
by: aj | last post by:
DB2 LUW 8.1 fixpak 14 Red Hat EL AS 4.4 I'm trying to diagnose some nocturnal CPU pressure, and am trying to understand the dynamic statement cache as it applies to LUW. The only doc/redbooks...
1
by: chanshaw | last post by:
Hey I'm trying to execute a simple statement but im getting a java.sql.Statement is abstract; cannot be instantiated. I just want to execute a simple select statement import...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.