java tutorial - How to connect access database in java - java programming - learn java - java basics - java for beginners
Connect access database in java
- There are two methods we are using to connect java application with the access database.
- Without DSN (Data Source Name)
- With DSN
- Java used with Oracle, mysql, or DB2 database.
Sample Code
Connect Java Application with access without DSN
- Below example, describe to connect the java program with the access database.
- Step 1: First your create a database "db.mdb" on d:sample folder
- Step 2: Create employee table as below -
- Table Name - wikitechy_employee
- emp_id (pK) Text,
- emp_name Text,
- emp_city Text,
- emp_salary number
- and insert a record emp_id-"w01278", emp_name-"Shym Andrews", emp_city- "US", emp_salary-75000
Sample Code
Connect Java Application with access with DSN
- To connect a Java application with Access database using JDBC-ODBC Bridge (type-1) Driver. We need to follow the below steps are,
- Go to control panel
- Go to Administrative tools
- Select Data Source (ODBC)
- Add new DSN name, select add
- Select Access driver from list, then click on finish
- Give a DSN name, click ok
Learn Java - Java tutorial - Create DSN Name - Java examples - Java programs