Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
|
Java Databases Discussion specific to working with Java Databases. For other Java topics, please see related Java forums. For database discussions not specific to Java, please see the Database category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2005, 03:48 AM
Authorized User
 
Join Date: Jul 2003
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why can't insert number value in Access2000?

I use Microsoft Access 2000 Database,I create a table named test,it contains one column named col1,it's type is number.
then I use statement like follows:

String str="insert test(col1) values(1)";
...
stmt.executeUpdate(str);

When I run it,it raise error:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] INSERT INTO statement grammer error.

But if column's type is Text,I use str="insert test(col1) values('1')"; it can run success.Why I can't insert number type value in Access 2000?

How to insert into number value in Access 2000?

 
Old June 19th, 2005, 08:00 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not use the same syntax for updating records, so I am not 100% sure. I noticed that your first example was missing the de-limiting characters '1'.

A more likely problem is your data type, your database is expecting a number, you are inserting a string. Try using a prepared statement:

st = conn.prepareStatement("UPDATE test SET col1 = ?");

st.setInt(1,yourInt);
st.executeUpdate();
st.clearParameters();

 
Old June 19th, 2005, 08:05 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, incorrect code:

st = conn.prepareStatement("INSERT INTO test (col1) VALUES (?)");

st.setInt(1,yourInt);

st.executeUpdate();
st.clearParameters();



 
Old June 21st, 2005, 03:00 AM
Registered User
 
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Mallik8
Default

ur problem is that command has syntax error ie.
 insert into test(col1) values(1).

try it .ok
all the best

P.Mallikharjuna Rao





Similar Threads
Thread Thread Starter Forum Replies Last Post
insert page number in crystal report revathy Crystal Reports 0 November 25th, 2008 04:28 AM
Divide, Insert a string and append a number from t Stuart Stalker SQL Server 2000 1 April 11th, 2006 06:58 PM
Insert Error Number "-2147217900" shabirmaher General .NET 0 August 3rd, 2005 05:30 AM
Upsizing to MSDE2000A from Access2000 megasime999 SQL Server 2000 0 October 21st, 2004 10:55 AM
access2000 and vb6.0 cydel VB How-To 1 September 5th, 2003 04:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.