i want to get records from msaccess when the pin number start from 'twt000'. I am using one variable name is pinnumber to store the value.

String pinnumber='twt000'

how to fetch records from msaccess database.

pst=con2.prepareStatement("Select * from pin_numbers where pin_number like '?*'");
					pst.setString(1,pin); 
					rs2=pst.executeQuery();

Please any one help me.

Your query is wrong. Do some studying about sql. If you want to use ? and prepared statements don't use quotes. Use this:

"Select * from pin_numbers where pin_number like ?"

pst.setString(1,pin);

If you want to search rows that have this: "twt000" inside their value, then this '*' will not work with sql.
Use:

"Select * from pin_numbers where pin_number like '%" + pinnumber + "%'";

Not prepared statement.

Edited 6 Years Ago by javaAddict: n/a

You can also use PreparedStatement which utilizes wildcards; just make sure that the "pin" you are setting already has those wildcard characters.

This question has already been answered. Start a new discussion instead.