170 likes | 300 Views
This guide outlines the step-by-step process to create a connection to a database using Microsoft Access. Begin by opening Access and creating a new blank database. Next, define your table structure in Design View, set the column names and data types, and save your changes. Afterward, configure the Data Source using the ODBC Data Sources in the Control Panel. Finally, learn to execute queries using Java's JDBC and SQL commands to manipulate and retrieve data from your newly created database.
E N D
2) A Blank Database will appear. 3) Right Click On Table1 : Table. 4) Select the “Design View” Option.
5) A Save As Dialog Box will Open. Enter the desired Name And Click on OK. 6) (This name will be used in SQL Query such as : String sql = “select * from StudInfo”;
7) Enter the Column names and their Data Types according to the requirement.
8) Close the StudInfo Table. 9) Click on “Yes” to save the changes to the table.
10) Double Click on the StudInfo : Table 11) Insert the values into the table. 12) Save the database using Ctrl + S. 13) Close the database.
18) From The “Create New Data Source” Window Click on “Microsoft Access Driver(*.mdb, *.accdb)” 19) And then click on Finish.
20) Enter the “Data Source Name”. (This name will be used in getConnection() method like, Connection con = DriverManager.getConnection(“jdbc:odbc:StudentDatabase1”); 21) Select the database that you created by selecting on “Select” option. Click on OK. After this step, connection to the database will be created.
Functions To Execute Queries : ResultSet executeQuery(String sql) throws SQLException : To execute queries such as static SELECT int executeUpdate(String sql) throws SQLException : To execute Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement. boolean execute(String sql) throws SQLException : To execute SQL statement like create table.