Syntax Error

ok I have searched for a good hour and found nothing that pertains directly to my problem so I need some help...Here is my populate method that connects to an Access DB and builds the resultset...Everything looks right however I keep getting this error when I run my test program...

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6998)

at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7155)

at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3151)

at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:378)

at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:284)

at orderSystem.Order.populate(Order.java:47)

at orderSystem.TestOrderInfo.main(TestOrderInfo.java:22)

any ideas Thanks ahead of time for any feedback...

publicboolean populate ()

{

boolean populated =false;

Connection con =null;

try

{

//register the JDBC driver

DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());

//connect to a database

con = DriverManager.getConnection("jdbc:odbc:Soundstream");

//execute a SQL statement

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

//show the results

ResultSet rs = stmt.executeQuery("SELECT * FROM Order WHERE orderID =" + orderID);[b]<<<<<<<<ERROR OCCURS HERE[/b]

if (rs.last())//determine if there is a record returned by sql execution

{

shippingAndHandling = rs.getDouble(2);

tax = rs.getDouble(3);

subtotal = rs.getDouble(4);

populated =true;

}

}

catch (Exception ex)

{

ex.printStackTrace();

}

finally

{

if (con !=null)

{

try

{

con.close();

}

catch (Exception ex)

{

ex.printStackTrace();

}

}

}

return populated;

}

>

[3244 byte] By [djmd02a] at [2007-10-3 5:22:33]
# 1

"Order" is a key word of SQL (Order By). In access it does not give you errors when you create tables/columns with the keywords, functions as names but it gives trouble when you try to access them.

If my memory is right access uses [ and ] to enclose the identifiers

so It might work if you modify the sql statement to

SELECT * FROM [Order] WHERE ....

If not you will have to use a different table name. Ex:- PurchaseOrder, CustomerOrder

LRMKa at 2007-7-14 23:29:36 > top of Java-index,Java Essentials,Java Programming...
# 2
Oh yeah I should have realized that...thank you so much it works now
djmd02a at 2007-7-14 23:29:36 > top of Java-index,Java Essentials,Java Programming...