I try to execute the following SQL-Statement (in my Java-application):
SELECT * FROM Tbl_Job WHERE jobname LIKE '%aa%';
But I can’t get the same (correct?) result using MS Access (2002):
SELECT * FROM Tbl_Job WHERE jobname LIKE '*aa*';
With this example Access will give me 400 datasets and my Java-application will only give me somewhat less I don’t know the exact number of datasets.
I tried to use the [*]-wildcard in my Java-app but it didn’t give me any datasets at all.
Besides I tried to replace the [‘]-character with the [“]-character but this didn’t work either.
I don’t know whether this is relevant or not but I think the *.mdb-file was created with MS Access (2000)
My Java code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection = DriverManager.getConnection("jdbc:odbc:_
Driver={Microsoft Access Driver_
(*.mdb)};DBQ=C:\database.mdb");
Statement stm = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stm.executeQuery(sql);
while(rs.next())
do_some_stuff();
Suggest you try this SQL statement both from Java and directly in Access.
If
num_rowsis the same in both cases, change the WHERE clause in your first query to match this one.If
num_rowsis not the same in both cases, please describe how they differ and which is correct.