views:

80

answers:

2

I'm trying to connect to an MSAccess database and retrieve some data. With simple examples all runs well but if i'm going to use some where clauses i get no data.

This example is ok:

PreparedStatement stm = con.prepareStatement("SELECT A.* FROM A");
ResultSet rs = stm.executeQuery();
rs.next();

The next example get no rows:

PreparedStatement stm = con.prepareStatement("SELECT A.* FROM A WHERE (((A.Name) LIKE ?))");
stm.setString(1,"*");
ResultSet rs = stm.executeQuery();
rs.next();

I don't know where the error lies: in the driver or in the sql syntax.

The sql statement is taken from the query builder in MSAccess.

All what is a little bit more complex in a where clause is a really hard to figure out. Is there any documentation reagrding sql syntax of MSAccess ?

Update

Yes in the jdbc sql statement i have to use "SQL standard" % wildcard while the Access sql builder is using *. Now going to query with dates =8-o

A: 

Do you, by any chance, mean the SQL wildcard character, '%', instead of '*', or are you literally looking for the character '*'?

Henning
+1  A: 

For the like statement to work you have to put the parameter between %:

PreparedStatement stm = con.prepareStatement("SELECT A.* FROM A WHERE (((A.Name) LIKE ?))");
stm.setString(1,"%like text%");
Bobby