Your table is called numeric
which is also an SQL data type. The SQL parser thinks its a data type and your query fails. If you have reserved keywords like this as table names you need to put the table name in parenthesis:
SELECT * FROM [numeric]
Pregunta
I have an access database and trying to use it in java. I want to select it and wrote a statement as
String sql="SELECT * from numeric;";
try
{
rs=s.executeQuery(sql);
while(rs.next())
{
System.out.println(rs.getString(1));
}
}
The executeQuery is throwing an exception as
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
I think the select statement I wrote is correct. Even if i write as
SELECT Webservice FROM numeric;
also gives me an error where Webservice is my column name.
Solución 2
Your table is called numeric
which is also an SQL data type. The SQL parser thinks its a data type and your query fails. If you have reserved keywords like this as table names you need to put the table name in parenthesis:
SELECT * FROM [numeric]
Otros consejos
You have to remove the trailing ;
at the end of your statement!
Usually you are seperating statements with a ;
, but since executing multiple statements in a single statement string is not allowed in JDBC by specification, you can't use semicolons.
In Access database the index starts from one, not zero. Identify the index of webservice
first, it mary be two, try out the following statement
System.out.println(rs.getString(2));