Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC JAVA DB connenting Office access..

Have Programming Question? Ask it here!
 
 
 


shackir puluckool
JAVA DB connenting Office access..
1 Answer(s)      3 years and 3 months ago
Posted in : JDBC


hai friends....iam shackir.. i did 1 program to connect OfficeAccess...in this program everything except insertions are working fine...i cant understand what is the problem..."ANY ONE PLEASE HELP ME"

ERROR IS : 3 SQl error in insertValues methord java.sql.SQLException: Driver does not support this function 0 at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(JdbcOdbcPreparedStatement.java:164) at associated.DataBaseConnetion.insertValues(DataBaseConnetion.java:229) at associated.DataBaseConnetion.main(DataBaseConnetion.java:294)

THE PROGRAM CODE IS HERE:

package associated;

import java.sql.*; import java.util.ArrayList; import java.util.List;

public class DataBaseConnetion {

public String partNumber,partName, availableStock,unitCP,unitSP,tax;;
public Double availableStockD,unitCPD,unitSPD,taxD;

private Connection connect;
private PreparedStatement pstm;
private ResultSet rs;
private String sql;
private int i,count,rownum;

//working
//    public void dataRetrieve(String itemNumber){
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> 
public DataBaseConnetion retrieveData(String partNumber){
   DataBaseConnetion dbcrd=new DataBaseConnetion();
    try
    {
        //loading the driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        //connection object created using DriverManager class
        //student_base is the name of the database
        connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

        Statement st=connect.createStatement();

        dbcrd.sql="select * from MyShopDetls where partNumber ='"+partNumber+"'";
        //      execute method to execute the query
        dbcrd.rs=st.executeQuery(dbcrd.sql);
        if(dbcrd.rs.next()){

            dbcrd.partNumber=dbcrd.rs.getString("partNumber");
            dbcrd.partName=dbcrd.rs.getString("partName");
            dbcrd.availableStock=dbcrd.rs.getString("availableStock");
            dbcrd.unitCP=dbcrd.rs.getString("unitCP");
            dbcrd.unitSP=dbcrd.rs.getString("unitSP");
            dbcrd.tax=dbcrd.rs.getString("tax");

        }else{
            dbcrd.partName="";
            dbcrd.availableStock="";
            dbcrd.unitCP="";
            dbcrd.unitSP="";
            dbcrd.tax="";

        }

        //closing the  statement  and connection object
        st.close();
        connect.close();
    }catch(SQLException sqe){
        System.out.println("SQl error from retrieve data");
    }catch(ClassNotFoundException cnf){
        System.out.println("Class not found error");
    }
    return dbcrd;
}// </editor-fold>                        

//working
 //List retrieveAllData()
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">       
public List retrieveAllData(){
    List ls=new ArrayList();
    try
    {
        rownum=rowNumber();
        DataBaseConnetion dbcr[]=new DataBaseConnetion[rownum];

        //loading the driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        //connection object created using DriverManager class
        //student_base is the name of the database
        connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

        Statement st=connect.createStatement();

        sql="select * from MyShopDetls e";
        //      execute method to execute the query
        rs=st.executeQuery(sql);

        while(rs.next()){
            dbcr[count]=new DataBaseConnetion();
            dbcr[count].partNumber=rs.getString("partNumber");
            dbcr[count].partName=rs.getString("partName");
            dbcr[count].availableStock=rs.getString("availableStock");
            dbcr[count].unitCP=rs.getString("unitCP");
            dbcr[count].unitSP=rs.getString("unitSP");
            dbcr[count].tax=rs.getString("tax");
            ls.add(dbcr[count]);
            count++;
        }

        //closing the  statement  and connection object
        st.close();
        connect.close();
    }catch(SQLException sqe){
        System.out.println("SQl error from retrieve all data");
    }catch(ClassNotFoundException cnf){
        System.out.println("Class not found error");
    }
    return ls;

}// </editor-fold>                        

 //working
//int rowNumber()
@SuppressWarnings({"unchecked", "empty-statement"})
// <editor-fold defaultstate="collapsed" desc="Generated Code">       
public int rowNumber(){
    try
    {
        //loading the driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        //connection object created using DriverManager class
        //student_base is the name of the database
        connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

        Statement st=connect.createStatement();

        sql="select * from MyShopDetls";
        rs=st.executeQuery(sql);
        for(i=1;this.rs.next();i++);
        i--;

        //closing the  statement  and connection object
        st.close();
        connect.close();
    }catch(SQLException sqe){System.out.println("SQl error from row number");
    }catch(ClassNotFoundException cnf){System.out.println("Class not found error");}
    return i;
}// </editor-fold>                        

//working
//int updateData(DataBaseConnetion dbc)
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">   
public int updateData(DataBaseConnetion dbc){
    DataBaseConnetion dbcL=new DataBaseConnetion();
    dbcL=dbcL.retrieveData(dbc.partNumber);
    if(dbc.partName.equals("")){dbc.partName=dbcL.partName;}
    if(dbc.availableStock.equals("")){dbc.availableStock=dbcL.availableStock;}
    if(dbc.unitCP.equals("")){dbc.unitCP=dbcL.unitCP;}
    if(dbc.unitSP.equals("")){dbc.unitSP=dbcL.unitSP;}
    if(dbc.tax.equals("")){dbc.tax=dbcL.tax;}

    int resultlen=0;

    try
     {
       //loading the driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        //connection object created using DriverManager class
        //student_base is the name of the database
        connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

        pstm=connect.prepareStatement("update MyShopDetls set partName=?, availableStock=?," +
                    "unitCP=?,unitSP=?,tax=? where partNumber=?");

        pstm.setString(1, dbc.partName);
        pstm.setString(2, dbc.availableStock);
        pstm.setString(3, dbc.unitCP);
        pstm.setString(4, dbc.unitSP);
        pstm.setString(5, dbc.tax);
        pstm.setString(6, dbc.partNumber);

        resultlen= pstm.executeUpdate();
        System.err.println("Details updated "+resultlen);
        //closing the prepared statement  and connection object
         pstm.close();
         connect.close();
       }
       catch(SQLException sqe){
         System.out.println("SQl error frm update");
        }
        catch(ClassNotFoundException cnf)
        {
         System.out.println("Class not found error");
        }
    return resultlen;
}// </editor-fold>                        

    //int insertValues(DataBaseConnetion dbc)
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">       
public int insertValues(DataBaseConnetion dbc){
    i=0;
    try{
        //loading the driver
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        //connection object created using DriverManager class
        //student_base is the name of the database
        connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

        Statement st=connect.createStatement();

        sql="select partNumber from MyShopDetls where partNumber ='aml'";
        rs=st.executeQuery(this.sql);

        if(rs.next()){
            i=0;
            st.close();
        }else{
               st.close();
        sql="insert into MyShopDetls (partNumber, partName, availableStock, unitCP, unitSP, tax) VALUES (?,?,?,?,?,?)"; 

        pstm=connect.prepareStatement(sql);      
        //      execute method to execute the query

        pstm.setString(1, "aml");
        pstm.setString(2, "Anti Medical Lang");
        pstm.setString(3, "34.9");
        pstm.setString(4, "66");
        pstm.setString(5, "75");
        pstm.setString(6, "0.0");

        i=pstm.executeUpdate(sql);

        pstm.close();
        }
        //closing the  statement  and connection object

        connect.close();
    }catch(SQLException sqe){
        System.err.println("SQl error in insertValues methord");
        sqe.printStackTrace();
    }catch(ClassNotFoundException cnf){
        System.err.println("Class not found error");
    }
    return i;
}// </editor-fold>                        

//working
//int deleteData(String partNumber)
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
 public int deleteData(String partNumber){

     i=0;
    try
 {
   //loading the driver
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    //connection object created using DriverManager class
    //student_base is the name of the database
    connect =DriverManager.getConnection("jdbc:odbc:MyShopDetls");

    sql="delete from MyShopDetls where partNumber=?";
    pstm=connect.prepareStatement(sql);
    pstm.setString(1,partNumber);
    i=pstm.executeUpdate();

    System.err.println("deletion sucess");
     //closing the prepared statement  and connection object
    pstm.close();
    connect.close();
   }
   catch(SQLException sqe)
   {
     System.out.println("SQl error");
    }
    catch(ClassNotFoundException cnf)
    {
     System.out.println("Class not found error");
    }
     return i;
 }// </editor-fold>

// public int iD; //static void main(String... args) public static void main(String... args){ DataBaseConnetion dbc=new DataBaseConnetion(); // DataBaseConnetion dbc1=new DataBaseConnetion(); // dbc.iD=5; dbc.partNumber="ask"; dbc.partName="Amplitude Shift Keying"; dbc.availableStock="20"; dbc.unitCP="1000"; dbc.unitSP="1300"; dbc.tax="0.5"; System.out.println(dbc.rowNumber()); System.out.println(dbc.insertValues(dbc));

}

}


Advertisement
View Answers

September 15, 2011 at 4:31 PM


At last i solved this problem ...

HOw:

I made this table through java program itself rather creating the table from Microsoft Access.

Those who need an example in Java DataBase connetivity can use this program code as an example.

If You can not understand this program. Then u send 1 mail for getting codes which is working... shackir007@gmail.com is mail id

Thank You



Related Tutorials/Questions & Answers:
JAVA DB connenting Office access..
JAVA DB connenting Office access..  hai friends....iam shackir.. i did 1 program to connect OfficeAccess...in this program everything except insertions are working fine...i cant understand what is the problem..."ANY ONE PLEASE
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
Advertisements
Want to access my Ms-access Db file which is placed inside the same Jar file
Want to access my Ms-access Db file which is placed inside the same Jar file  how do i access my Ms-Access file placed in the same jar file where my application code/class file r present??? Want to access it via Code
Java and DB - Java Interview Questions
Java and DB   What is the difference between database null and Java null
db error - Java Beginners
db error  Hi, how to insert text area content into database...://192.168.10.126/"; String db = "roseindia"; String driver = "com.mysql.jdbc.Driver...(driver); con = DriverManager.getConnection(url+db, user, pass
Java DB
Java DB       Java DB is an open source Apache Derby database supported by Sun. Java DB is completely written in the Java programming language having the functionality write once run
java connecting to oracle db
java connecting to oracle db  PLZ SAY ME HOW TO INSERT THE VALUES INTO ORACLE THIS IS THE CODE: import java.io.*; import java.sql.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import
implement microsoft office
implement microsoft office   how implement microsoft office in my java swing project ,or when microsoft office is not install then file open in defualt text editar.please send me source code
java connecting to oracle db - JDBC
java connecting to oracle db  how to connect oracle data base with java application?  Hi Friend, Follow these steps: 1) Import the following packages in your java file:*********** import java.sql.*; import
Java access modifiers
Java access modifiers  If a class is declared without any access modifiers, where may the class be accessed
Access and Java - Java Beginners
Access and Java  A construction company has specialized in planning...: MS Access, A employee database using Access and SQL which keeps the records... the employee records in EXCESS and convert it to JAVA programing with solid and simple
Entity DB design pattern - Java Interview Questions
Entity DB design pattern  I want the information for Entity DB design pattern
java access resource bundle
java access resource bundle  java access resource bundle   //resource bundle <resource-bundle> <base-name>/resources...; // access bundle import java.util.ResourceBundle; ResourceBundle rb
how to access the MS ACCESS database with java
how to access the MS ACCESS database with java   how to access the MS ACCESS database with java how can we insert,delete,update,search records of ms access with java   Java MS Access database connectivity Follow
car licensing office
. *Then the customer receives a request ID from the office. *The customer's request... by passing the number of employees working in the office. Provide the class... is not served at the office or the employee serving the brand cannot accept more
car licensing office
. *Then the customer receives a request ID from the office. *The customer's request... by passing the number of employees working in the office. Provide the class... is not served at the office or the employee serving the brand cannot accept more
car licensing office
. *Then the customer receives a request ID from the office. *The customer's request... by passing the number of employees working in the office. Provide the class... is not served at the office or the employee serving the brand cannot accept more
Access Infotech - Java Beginners
Access Infotech  Best Growing IT Company in hyderabad(Access Infotech) Access Infotech unit 4b,4th floor, topaz building, punjagutta, hyderabad-500082. for more queries contact tel:-04030584311 www.accessinfotech.in
how to access the MS ACCESS database with java - Java Beginners
how to access the MS ACCESS database with java  how can we insert,delete,update,search records of ms access with java
Access - Java Beginners
Access  Access infotech Best growing company in IT industry in hyderabad Best place to work beginning IT careers  Expert:peter Access infotech Best growing company in IT industry in hyderabad Best place to work
java &ms access - JDBC
java &ms access  Seasons Greetings, Am, creating an application for a food festival using Java swing as front end and MS access as Backend... ve managed to populate the JComboBox using MS Access. The problem is only 8 per
what is the difference between access specifiers and access modifiers in java?
what is the difference between access specifiers and access modifiers in java?  what is the difference between access specifiers and access modifiers in java
Java code to executr db query if user directly closes the browser
Java code to executr db query if user directly closes the browser  How to execute a database query if the logged in user idle for 15 mins or he will directly close the browser.........PLS help it out
Store image from html img tag into mysql db using java
Store image from html img tag into mysql db using java  Hi. How to get the image displayed in the < img > tag of HTML and store it in the mysql database using java? Thanks in advance
access modifier - Java Interview Questions
access modifier  can someone explain to me all about java access modifier including the defualt modifier.  Hi Friend, Access Modifiers... will be available to all its derived classes. Default - If no access modifier
stock checking in java with backend as access
stock checking in java with backend as access  Hi, I am doing a project in java,Can i able to know how to check the stock availability of a product in java...my back end connectivity is ms-access from the database ,i hv
Access Infotech, Hyderabad - Java Beginners
Access Infotech, Hyderabad  Access infotech is the best suitable for every software compay
how to access the details - Java Beginners
how to access the details  how to access the detailsclass E { String name; String no;string place; E(String n,String n,String p) { ... ... .... } public String... no)and retrive all the details of the person which is not given
methods and access specifiers in java - Java Beginners
methods and access specifiers in java  i am a java beginner..give me the rules f methods and access specifiers  Hi friend, visit for more information: http://www.roseindia.net/java/ http://www.roseindia.net
access
access   This is Nitha Sriram i am having a problem that, i am having a combo box in the JSP page when i select an item from that i am calling the onchange function. In javascript i am getting the value now i want to pass
Accessing Ms access data in JAVA GUI Envi.
Accessing Ms access data in JAVA GUI Envi.  Q.How to insert data into ms access data in java using swing ? Q.How to slove (access denided ("java.lang.RuntimePermission" "accessClassInPackage.sun.jdbc.odbc")" these exception
Package Access Specifier - Java Beginners
Package Access Specifier  Hello Friends, I have created a Pkg named BCA , iN this Package i declare two classes name : - Test Class & House Class House is the Public Class I saved it with House.java File
Access Report to Java Application - Java Beginners
Access Report to Java Application   Hello Sir can I connect Access Report to Java Application when i Enter Student ID in JTextField then the Appropriate Records From the Database will Be Shown in to Access Report. plz Help
Access Modifiers in java
Access modifiers are used to specify the visibility and accessibility of a class, member variables and methods. There are four type of access modifiers public protected private default For more details about access
java servlet connectivity problem with access
java servlet connectivity problem with access  Import java.sql javax.servlet //all packages entered try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc
how to access windows registry information using java?
how to access windows registry information using java?  can any one help me how to access windows registry information using java
MS Access connct using flex with java
MS Access connct using flex with java  Hi All, Can anybody help me how to connect to the MS access database and getting the data using flex in java technology with tomcat server
Need Help-How to store input parameter in DB through Java Bean - JSP-Servlet
Need Help-How to store input parameter in DB through Java Bean  Hello...(Its Java Bean) which create a connection from DB and insert the data. At run... are not store in Ms-Access. I store the input parameter through Standard Action
to access a date object - Java Server Faces Questions
to access a date object  How to access a date value from the screen of Visual JSF to the DataBase java-Derby using NetBeans6.5.  Hi friend, For solving the problem visit to : http://www.roseindia.net/jsf/visual
DB Insert
DB Insert  How to insert XML data into a database column? Column data type is CLOB
Create Reports in Java with access database - Java Beginners
Create Reports in Java with access database  Hello Sir How to Create Reports of Any Type using Java when i submit data is stored in the MS access database,but when I click on PRINT Button then it will display it into either Text
Os details access in java - Development process
Os details access in java  Hi, can anyone give me the code of accessing OS details in java such as os name,os type ,kernal etc.etc.?  Hi...() method of Java. Here is the few links which will help you in solving your problem
assert,access modfier - Java Interview Questions
assert,access modfier  can someone explain to me what assertion is all about in java. and what access modifier is transient  Hi Friend, To learn Assertion, please visit the following link: http://www.roseindia.net
db
db
db connectivity
db connectivity  hi i am beginner in objective c lang and having knowlwgde of basic syntax of this lang and need statements that can be used to connect to sqlite. please do send me the simple example code. i am using GNUstep
java to MS Access conectivity - Swing AWT
java to MS Access conectivity  give me source code to stored... database on the ACCESS.  Hi Friend, Follow these steps: 1. Open...(ODBC) 2. Open User DSN tab 3. Add a user DSN 4. Select Microsoft Access Driver
DB connectivity - EJB
DB connectivity  DB connectivity
 

 

 

DMCA.com