Home Answers Viewqa JDBC JAVA DB connenting Office access..

 
 


shackir puluckool
JAVA DB connenting Office access..
1 Answer(s)      2 years 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));

}

}

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 Pages:
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
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
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
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
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 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
Server DB connection - JDBC
Server DB connection  Hello Guys I want to connect two databases at the same time but it looks like the java is only picking up the second database. One database is on my localhost and the other one is on server, I want
Comparison of corresponding rows in a DB
Comparison of corresponding rows in a DB  How to compare corressponding rows in a database using Java????? ex...!!! Thankin u
Entity DB design pattern - Java Interview Questions
Entity DB design pattern  I want the information for Entity DB design pattern
db
db
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
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
ms access
ms access  how to delete the autonumber from ms access using java delete code
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
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me dis is my
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me dis is my
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me dis is my
ms access
has to login . i already created ms access page and inserted values throught... and password" from my ms access............and detail in register(table in my ms access) need to display values in jsp .............please help me dis is my
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
MS ACCESS
-> data sources. 2)Click Add button and select the driver Microsoft Access... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding... = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb
MS ACCESS
-> data sources. 2)Click Add button and select the driver Microsoft Access... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding... = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb
MS ACCESS
-> data sources. 2)Click Add button and select the driver Microsoft Access... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding... = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb
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 - 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
jfreechart displaying chart from access database
jfreechart displaying chart from access database  I have these 2... ArrayList<database>(); database db; try { int...); out.println("abc"); db=new database(r,nm,m1,m2,m3,m4); v.add(db
retrieving info from DB using struts?
retrieving info from DB using struts?  Hi. I was looking info about retrieving info from a database using struts. I need a .java that I suppose connects to a database and show the info on a jsp. Somebody could help me
URGENT: Export Table in Oracle db to CSV file
URGENT: Export Table in Oracle db to CSV file  Hi, Could you basically help me by providing a program in Java. I want a program to connect and export a table in the oracle database to a folder in my local harddrive. Thankyou
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
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
Hibernate Performing the usual DB operations
HIBERNATE-BASICS Hibernate Performing the usual DB operations... the usual DB operations. Hybernate2 can be downloaded from http... a java class, which will be automatically persisted to Relational Database
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
Access web.xml init parameters
Access web.xml init parameters  How to access web.xml init parameters from java code
How to access Subclass?
How to access Subclass?  How to access subclass in java? please tell me the syntex with an example
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
Access Infotech, Hyderabad - Java Beginners
Access Infotech, Hyderabad  Access infotech is the best suitable for every software compay
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
Data Access Object
Data Access Object  Hi sir/madam please give me some tutorial/example about Data Access Object   Hi Please Find the example of Java Data Access Object http://www.roseindia.net/tutorial/java/jdbc
sample jsp-servlet-service-db program
sample jsp-servlet-service-db program  <%@ page language="java...; <%@ page language="java" contentType="text/html; charset...; <% Connection conn=null; Statement stmt=null; try { DB obj=new DB
Access Modifiers
Access Modifiers       Access Modifiers : Access modifiers are used to specify the visibility and accessibility of a class, member variables and methods. Java provides