I can't find the mistake, I get this error:
Error: net.ucanaccess.jdbc.UcanaccessSQLException: unexpected token: = required: AS
This is my code. Can you help me find it? Thanks in advance.
package database;
// Imports
import java.sql.*;
public class DBConnect {
// Path to Database
final static String DB = "jdbc:ucanaccess://src/database/DB.accdb";
// Declareren
public static String strAntwoord1;
public void Connect(){
// Initialiseren
Connection con;
Statement s;
ResultSet rs = null;
// Try Database Path/Connection to get Variables
try {
con = DriverManager.getConnection(DB);
s = con.createStatement();
rs = s.executeQuery("SELECT * FROM tblAntwoorden WITH ID=1");
if (rs != null) while ( rs.next() ) {
strAntwoord1 = rs.getString("Antwoord");
if (strAntwoord1 == "Indonesië"){
System.out.println("Antwoord found.");
}
}
s.close();
con.close();
} catch (SQLException e) {
System.out.println("Error: " + e);
}
}
}
It's a task for school and I've got to solve this before midnight. So I've got 1 hour left. Thanks in advance for the people who are willing to help me.
Benji, your SQL has to be perfectioned. Not WITH but WHERE:
SELECT * FROM tblAntwoorden WHERE ID=1
The message says "an alias declaration is expected", e.g.,
SELECT * FROM tblAntwoorden AS a WHERE a.ID=1
yet I hope this suggestion from a different timezone helps you to do the next homework.