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.
SELECT Count(*) AS num_rows FROM Tbl_Job WHERE jobname ALike '%aa%';
If num_rows
is the same in both cases, change the WHERE clause in your first query to match this one.
If num_rows
is not the same in both cases, please describe how they differ and which is correct.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.