Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
How to add a new row in the MS Access back end through JAVA.
I'm using an Eclipse tool.
Posted 24-Nov-12 1:29am
Edited 5-Dec-12 9:09am
v3
Comments
OriginalGriff at 24-Nov-12 7:34am
   
Perhaps, you should consider the advantages of being a little more polite.
You do not pay our wages.
You do not get charged for our services.
So you do not have the right to give orders and act like a petulant little schoolboy.
 
Perhaps, if you edit your question, change it to explain your problem and ask in a polite way instead, you might get a better response.
Just a thought.
You can use the "Improve question" widget to edit your question.
GeekBond at 5-Dec-12 14:06pm
   
:thumbsup:
Abhishek Pant at 24-Nov-12 11:57am
   
my 5 to OriginalGriff; check this is it helps you Inserting Data Rows to MS Access Database[^]

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Java MS Access database connectivity
 
Follow these steps:
 
1)Go to the start->Control Panel->Administrative Tools-> data sources.
 
2)Click Add button and select the driver Microsoft Access Driver(*.mdb).
 
3)After selecting the driver, click finish button.
 
4)Then give Data Source Name and click ok button.
 
5)Your DSN will get created.
 
6) Restart your compiler and compile your java code.
 
For Inserting Data:
import java.sql.*;
class AccessDatabase{
    public static void main(String[] args){
        try{
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           String name="roseindia";
           String address="delhi";
           int i=st.executeUpdate("insert into user(name,address) values('"+name+"','"+address+"')");
           System.out.println("Row is added");
           }
        catch(Exception e){
            System.out.println(e);
        }
    }
}
For deleting data:
import java.sql.*;
class AccessDatabase{
    public static void main(String[] args){
        try{
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con = DriverManager.getConnection("jdbc:odbc:student");
           Statement st=con.createStatement();
           String name="roseindia";
           String address="delhi";
           int i=st.executeUpdate("delete from user where id=4");
           System.out.println("Row is deleted");
           }
        catch(Exception e){
            System.out.println(e);
        }
    }
}
  Permalink  
Comments
Sachin Shinde11088 at 24-Nov-12 23:08pm
   
Thanks for helping me yaar..
Tamer Hatoum at 26-Nov-12 1:23am
   
your welcome ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 365
1 Sergey Alexandrovich Kryukov 319
2 CPallini 275
3 DamithSL 214
4 Maciej Los 185
0 OriginalGriff 5,455
1 DamithSL 4,457
2 Maciej Los 3,885
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,115


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100