Write the java Program which is given: NameSearch.java
Create an Access Database say db1
Which has 3 fields in the table named staff. First field as ID, second
field as Name and third field as Age
Create the DSN (Data Source Name). Follow the steps given
below.
a)Go to Control Panel you will get figure as given below
b) Double Click Administrative Tools you will get the figure as given below
c) Double click on to ODBC data source you will get the figure as given below
d) Click on to “System DSN” you will get the figure as given below(Tables may be different in your Computer)
e) Click on to “Add” button you will get the figure as given below
f) Now select Microsoft Access Driver then click “Finish” you will get the figure as given below
g) Give a DSN name say ABC then click on to “Select” to map the Database which is already created as db1
(Select the database which you want to map to the DSN name ABC) you will get the figure as given below
h) Click OK
i) Click OK
j) Click OK
In the program use DSN name
String dbUrl="jdbc:odbc:ABC";
(Here ABC is the DSN which you have created)
Use the table name from where you want to read the data
ResultSet rs=stmt.executeQuery("Select * from staff where Name like '"+s+"%'");
(Here staff is the table name and Name is the field name in the table)