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



Home Answers Viewqa JDBC JAVA DB connenting Office access..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shackir puluckool
JAVA DB connenting Office access..
1 Answer(s)      3 years and 7 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 access data yearly from DB in C# ?
How to access data yearly from DB in C# ?  how to access data yearly from database in C#. I have code but i m not able to retrieve data yearly from DB table. string date1 = dateTimePicker1.Value.Date.ToString("dd/MMM/yyyy
Advertisements
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
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
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
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
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
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
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
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
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 - 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
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
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
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
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
Advertisements
 

 

 

DMCA.com