Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > Java Databases
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 19th, 2005, 03:48 AM
Authorized User
Join Date: Jul 2003
Location: , , .
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)";

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?

  #2 (permalink)  
Old June 19th, 2005, 08:00 AM
Friend of Wrox
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts

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 = ?");


  #3 (permalink)  
Old June 19th, 2005, 08:05 AM
Friend of Wrox
Join Date: Jul 2004
Location: , , .
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts

Sorry, incorrect code:

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



  #4 (permalink)  
Old June 21st, 2005, 03:00 AM
Registered User
Join Date: Apr 2005
Location: vijayawada, AP, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Mallik8

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

try it .ok
all the best

P.Mallikharjuna Rao

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 08:17 PM.

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