Step by step guide:
1.Create a database in ms access and add a table
2.Add columns to the table.
3.Go to control panel->Administrative Tools
->JDBC-> System DSN
4.In System DSN tab click on add ,choose
Microsoft access driver ,then you will get a
dialog box opened ODBC Microsoft access setup
mention the data source name in it and in
databases click on select button and choose
your .mdb file that is created in step1.
5.Register the driver using
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
6.Connect to the database
Connection con = DriverManager.getConnection
(URL,userid,password);
url= Jdbc:Odbc:
userid and password are empty in case of MS access.if it oracle default userid is scott password is tiger . 95-707 Java Programming, Using Java:: Using cluster machines. GridCity files. Java 2 SDK. Compiling and Command Prompt (MS-DOS) Access this selection box by left-clicking on the http://privacy.cs.cmu.edu/courses/java/javause.htmlHOME | jCIFS: CIFS in Java:: various RPC handle operation access masks, uncommenting some padding code examples/KerberosAuthExample.java is included to demonstrate using this package http://jcifs.samba.org/HOME |
Ex: Connection con = DriverManager.getConnection JDBC Type-4 driver for MS Access - ITtoolbox Groups:: hI Rajesh Type 4 driver does not support for MS Access RE: sending sms using java?? (Groups) Reference Material for This Group http://java.ittoolbox.com/groups/technical-functional/javariver-for-ms-access-66118HOME |
( Jdbc:Odbc:msac, ,);
Source Code
import java.sql.*;
import java.io.*;
class JdbcDemo1
{
Connection con;
Statement stmt;
ResultSet rs;
JdbcDemo1(){
try{
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
con = DriverManager.getConnection( Jdbc:Odbc:msac, ,);
stmt = con.createStatement();
rs = stmt.executeQuery(SELECT * FROM Table1);
while (rs.next()) {
String x = rs.getString(name);
int s = rs.getInt(age);
System.out.println(x:+x+s+s);
}
}catch(SQLException e){
System.out.println(Hello World!+e);
}catch(ClassNotFoundException e){
System.out.println(purni+e);
}
}
}
class JdbcDemo
{
public static void main(String args[]){
new JdbcDemo1();
}
}
My rights and duties- employer asks me to provide testimony in its civil lawsuit
Asian or Pacific Islander?
|