HOW TO CREATE TABLE IN MS ACCESS:
Open microsoft access and new blank desktop database then select create option then TableDesign empty table will be created as shown in below picture.
After this fill this table according to your need and set data type as long text or short text as shown in below picture.
Then press cntrl+s to save your table and change table name with data because this name will be used in code.Our table is successfully created.In next step save ms access file in your project folder,save database file name as data and during saving you file select access 2000 database as a file type.
CREATING DATA SOURCE FOR DATA BASE:
In order to connect our application with database we require a dsn so create a dsn.Go to control panel>>Administrative tools then open ODBC Data Sources window will open like this
Now click on add button on this window to create DSN now new window will open select microsoft access driver option as shown in below picture.
Now select your ms access file from where you have saved change data source name with login.After selecting finish button our database will created our next step is to check whether out database is working fine or not.
HOW TO CHECK JDBC CONNECTION:
We have created our database our last step is to check our database connection is fine or not create a new java file and paste below code in it if your database connection is fine it will print Successfully Connected with database
import java.sql.*;
public class projava {
public static void main(String[] args) {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:login");
cn.close();
System.out.print("Successfully Connected with database");
}
catch (Exception ex)
{
System.out.print(ex);
}
}
}
No comments:
Post a Comment