By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Insert into error with java and MS Access

P: n/a
Hi, I have an Access database that I am creating a java front end to.
I am trying to insert a record into a table and get a problem whenever
I try to insert into my "Number" column.

Here is my table schema:
Column 1 Name: Number Type: VARCHAR
Column 2 Name: Street Type: VARCHAR
Column 3 Name: Phone Type: VARCHAR
Column 4 Name: Comments Type: LONGCHAR
Column 5 Name: Pets Type: VARCHAR
Column 6 Name: id Type: VARCHAR
Column 7 Name: Phone2 Type: VARCHAR
Column 8 Name: Email Directory Type: BIT
Here is my insert statement that creates the error:
queryString = "INSERT INTO Homes (id,Street,Number) VALUES ('5000a',
'Test Bend','5000');" ;
m_statement.executeUpdate(queryString);

This statement works, however:
INSERT INTO Homes (id,Street,Phone) VALUES ('5000b', 'Test
Bend','555-555-1234');

Here is the error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
statement.
[Ljava.lang.StackTraceElement;@1a786c3
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
2BaCook wrote:
Hi, I have an Access database that I am creating a java front end to.
I am trying to insert a record into a table and get a problem whenever
I try to insert into my "Number" column.

Here is my table schema:
Column 1 Name: Number Type: VARCHAR
Column 2 Name: Street Type: VARCHAR
Column 3 Name: Phone Type: VARCHAR
Column 4 Name: Comments Type: LONGCHAR
Column 5 Name: Pets Type: VARCHAR
Column 6 Name: id Type: VARCHAR
Column 7 Name: Phone2 Type: VARCHAR
Column 8 Name: Email Directory Type: BIT
Here is my insert statement that creates the error:
queryString = "INSERT INTO Homes (id,Street,Number) VALUES ('5000a',
'Test Bend','5000');" ;
m_statement.executeUpdate(queryString);

This statement works, however:
INSERT INTO Homes (id,Street,Phone) VALUES ('5000b', 'Test
Bend','555-555-1234');

Here is the error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO
statement.
[Ljava.lang.StackTraceElement;@1a786c3


Just guessing.

Phone numbers usually aren't stored as numbers in a table...usually they
are strings. So I can understand why the phone number works if that is
the case. I'm not sure why you want to stuff a string into a number
field unless the field Number, in the table, is a string. What happens
if you remove the single quotes around the number 5000?

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.