Hi friends,
Today i'm going to teach you how you can connect your MS-Access
Database with java program (JDBC).
I hope you'l enjoy.
1.open ms Access | create database | save at your Location
2.Control Panel\Administrative Tools
3.click User dsn OR system dsn
4.click add
5.select Microsoft Access Driver(*.mdb,*.accdb)
6.finish
7.Give name for dsn
8.click select
9.give the path to your database
10.click ok(You will see your dsn in the list);
write java program as follow
import java.sql.*;
import java.io.*;
import java.util.*;
class dbconnect1
{
public
static void main(String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection
con=DriverManager.getConnection("jdbc:odbc:xyz","","");
System.out.println("Connection
established successfully");
}
catch(Exception
e)
{
System.out.println("Error"+e);
}
}
}
note:=(here XYZ is the dsn name you just created in step 7th step)
Thanks,
Tutorial by: Prakash Joshi
No comments :
Post a Comment