How can I Insert data into my msaccess Database table

Hello all,
I am new to Java programming and I have problem that how can i insert name into my database table.
The code which i have written is following:
String filename = "d:/test.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}";
Connection con = DriverManager.getConnection(database,"","");
String s = String.valueOf(text.getText());
int k =10;
Statement st = con.createStatement();
st.execute("create table Test123(name text)");
st.execute("INSERT INTO Test123 values" +s);
on the INSERT program throws exception???
can any one help me how to insert data into tabel.
Thanks

he INSERT program throws exception???
can any one help me how to insert data into tabel.I have never used the jdbc driver to access, but what do you think that the flag READONLY=true means? An insert is not a read.
Kaj

Similar Messages

  • How can I insert data into the standard CRM tables ?

    Hi Experts,
    Scenario----
    I need to download few attributes (fields) from SAP MDM to SAP CRM via SAP XI. I'm using the 'COMT_PRODUCT_MAINTAIN_API' API for it.
    The attributes(fields) that are present in the strucutres of API are downloaded into CRM system (by executing the Inbound proxy that is created based on the Message Interface created on XI) by calling the functions present in the API.
    And for those fields that are not present in CRM, but need to be downloaded into CRM, I'm creating the Set Type attributes in CRM, which get appended to the API.
    My query is:
    There are fields in CRM into which I need to insert the values. But they are not listed in the API. So, how can I insert(/download) the values into these standard fields?
    Regret the long description. Intended to be clear.
    TIA. Points will be awarded.
    Regards,
    Kris
    Edited by: Kris on Jul 21, 2008 8:00 AM

    he INSERT program throws exception???
    can any one help me how to insert data into tabel.I have never used the jdbc driver to access, but what do you think that the flag READONLY=true means? An insert is not a read.
    Kaj

  • How can i insert data into DB from my page programatically in Oracle ADF..?

    Hai, this is praveen.
    I have created  an EO and VO, when i have inserted data by dragging and dropping from DataControl -->Operations-->Create. I have successfully inserting data. But how can i do it programatically. What are the pre-defined steps that i can use over there to insert data into table programatically. Could u plz help me?

    Hi,
    You have to create an action Listener in the bean for any button.
    Then call an AM method.
    In that you have to do the following
    ViewObject yourVO = getYourVO();
    Row r = yourVo.createRow();
    r.setAttribute("Column1", value1); //the name of column should be as it is in your vo attribute.
    yourVO.insertRow(r);
    this.getDbTransaction().commit();
    Thanks

  • I can insert data into an access database, but I need to querry the database for specific information. How do I do it?

    I can insert data into an access database, now I need to do some simple querries such as selecting all records that are greater than a certain value or = a certain value. How can I return only the selected records?

    If you don't want to spend any money, then instead of ActiveX, I would recomend LabSQL from Jeffrey Travis. I use it instead of the Connectivity toolkit and have had no problems. Besides being free, you have the advantage of being able to use it with any database. ActiveX ties you to Access and you upgrade your version of Access and find the properties and methods are different, you've got a lot of reprogramming to do.

  • How can I load data into table with SQL*LOADER

    how can I load data into table with SQL*LOADER
    when column data length more than 255 bytes?
    when column exceed 255 ,data can not be insert into table by SQL*LOADER
    CREATE TABLE A (
    A VARCHAR2 ( 10 ) ,
    B VARCHAR2 ( 10 ) ,
    C VARCHAR2 ( 10 ) ,
    E VARCHAR2 ( 2000 ) );
    control file:
    load data
    append into table A
    fields terminated by X'09'
    (A , B , C , E )
    SQL*LOADER command:
    sqlldr test/test control=A_ctl.txt data=A.xls log=b.log
    datafile:
    column E is more than 255bytes
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)
    1     1     1     1234567------(more than 255bytes)

    Check this out.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1006961

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • In ADF how can i insert data in multiple table if they have foreign key

    I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
    Thnak you very much.

    Hello,
    Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
    1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
    2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
    3> i made that association composite by clicking the checkbox
    4> i created 2 VO from 2 EO.
    5> put those VO in Application Module.
    6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
    Now what to do please?

  • How can i update data in okc_k_items and csi_item_instances tables?

    How can i update data in okc_k_items and csi_item_instances tables?
    by EBS .
    Thanks.

    For csi_item_instances table, you can use the following API:
    CSI_ITEM_INSTANCE_PUB.UPDATE_ITEM_INSTANCE
    For okc_k_items, try using the following API:
    OKC_CONTRACT_ITEM_PUB.UPDATE_CONTRACT_ITEM
    Hope this helps!

  • Is it possible to insert data into a MySQL database with Java?

    Hello everyone!
    I would like to know, if it's possible to insert data into a MySQL database, with a JFrame inside a servlet?
    When the JFrame is first created it calls this method:
         * Connects the servlet with the MySQL database.
        private void connect(){
            try{
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/data", "root", "omfg123");
            }catch(ClassNotFoundException cnfe){
                cnfe.printStackTrace();
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }Then, when you click the "Add" button, it executes this code:
                add.addActionListener(new ActionListener(){
                    @Override
                    public void actionPerformed(ActionEvent ae){
                        String employee = employeeName.getText();
                        String[] args = employee.split(" ");
                        firstName = args[0];
                        lastName = args[1];
                        execute();
                });And this is my "execute()" method:
         * Connects the servlet with the MySQL database.
         * - And executes the SQL queries.
        private void execute(){
            try{
                PreparedStatement statement = connection.prepareStatement("insert" +
                        " into employees values(" + firstName + ", " + lastName
                        + ")");
                ResultSet result = statement.executeQuery();
                String fullName = firstName + " " + lastName;
                printer.write("Employee " + fullName + " added.</br>");
            }catch(SQLException sqle){
                sqle.printStackTrace();
        }But when I click the "Add" button, nothing happens.

    This is what I use to insert into mysql. It works on windows.
    try {
                Class.forName("com.mysql.jdbc.Driver");
                String connectionUrl = "jdbc:mysql://" + loadip + "/custsig?" +
                        "user=root&password=";
                Connection con = DriverManager.getConnection(connectionUrl);
                newproc = jTextField1.getText();
                newsoft = jTextField2.getText();
                newdeb = jTextField3.getText();
                newcust = jTextField4.getText();
                if (newcust.equals("")) {
                    errorsig12 = 1;
                    jLabel1.setForeground(new java.awt.Color(255, 0, 0));
                } else if (newsoft.equals("")) {
                    errorsig12 = 1;
                    jLabel2.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newproc.equals("")) {
                    errorsig12 = 1;
                    jLabel3.setForeground(new java.awt.Color(0, 0, 0));
                } else if (newdeb.equals("")) {
                    errorsig12 = 1;
                    jLabel4.setForeground(new java.awt.Color(0, 0, 0));
                if (errorsig12 == 0) {
                    PreparedStatement ps = con.prepareStatement("insert into customer set cust_name = ?,  software = ?, processor = ?, debit = ?");
                    ps.setString(4, newdeb);
                    ps.setString(3, newproc);
                    ps.setString(2, newsoft);
                    ps.setString(1, newcust);
                    int rs = ps.executeUpdate();
            } catch (SQLException eg) {
                System.out.println("SQL Exception: " + eg.toString());
            } catch (ClassNotFoundException cE) {
                System.out.println("Class Not Found Exception: " + cE.toString());
            }

  • Can't insert data into atable

    I have a block with several database text items, such as studname, studno, grade1, grade2, grade3 and total.
    I want the total text box to be a calculatd item, so i set the "calculation mode" for the total text box to "formula" and in the "formula" property I wrote the following: :evaluation.grade1 + :evaluation.grade2 + :evaluation.grade3.
    So far so good, but when i run the form and insert data and then try to save...I get an error "frm:40508" telling me "unable to save".
    Any help please

    Thank you steven for your reply;
    I still get the error, I can insert data into the same table using SQL*plus but i can't insert using forms developer.
    I did as you said and looked in the help menu, it says "wrong SQL statement" "ORA-01747:user.table.column"
    I didn't write the SQL statemnet....its written automatically by forms.
    I also, get this error "ora-00936: expression missing" when i try to query qnd execute the table using forms.
    Any help please??

  • How To Insert Data into a Access Database from a PDF File

    Hi All,
    Could anyone help me to insert PDF form data to an MS Access database.I am new to this and I would appreciate if anyone can help me at the earliest.
    Thanks,
    Deepti

    You can submit your PDF to a server-side script (ASP/PHP), and store the new record in a MS Access database.
    For more information on how to store your PDF submission in a database, please visit:
    http://www.fdftoolkit.net

  • How can I insert data from a cfloop?

    I have a query that outputs into a cfloop. What I need it to do is insert into an access database when the changes have been made. I have looked at several tutorials but they all offer different solutions than what I am looking for. My cflloop is:
    <cfoutput>
    <cfloop query="update" >
    <tr>
    <td><input type="text" name="meeting_date" value="#meeting_date#" /></td>
    <td><input type="text" name="contact_first" value="#update.contact_first#" /></td>
    <td><input type="text" name="contact_last" value="#update.contact_last#" /></td>
    <td>Attended <input type="checkbox" name="attended" value="yes" /></td>
    <td><input type="text" name="leads" size="3" /></td>
    </tr>
    </cfloop>
    </cfoutput>
    I then try to insert into the database with:
    <cfset j = "1">
    <cfloop index="i" from="1" to="#update.recordcount#">
    <cfset meeting_date = "Form.i#j#">
    <cfset contact_first = "Form.i#j#">
    <cfset contact_last = "Form.i#j#">
    <cfset attended = "Form.i#j#">
    <cfset leads = "Form.i#j#">
    <cfset meeting_date = Form["i#j#"]>
    <cfset contact_first = Form["i#j#"]>
    <cfset contact_last = Form["i#j#"]>
    <cfset attended = Form["i#j#"]>
    <cfset leads = Form["i#j#"]>
    <cfquery datasource="#application.Database#">
    INSERT INTO quarterly (meeting_date, contact_first, contact_last, attended, leads)
    VALUES ('#meeting_date#', '#contact_first#', '#contact_last#','#attended#',leads)
    </cfquery>
    <cfset j=j+1>
    </cfloop>
    Any ideas as to how to get my cfloop to insert into my database? I don't think I can lose anymore sleep over this. Thanks,

    It's because of the way of your coding is quite wrong. Because we didn't give specific name for each individual input and didn't call specific value from each inputs.
    Here is your code I've fixed already. Check it out.
    <cfoutput>
         <cfloop query="update" >
         <tr>
              <td><input type="text" name="meeting_date#currentrow#" value="#meeting_date#" /></td>
              <td><input type="text" name="contact_first#currentrow#" value="#update.contact_first#" /></td>
              <td><input type="text" name="contact_last#currentrow#" value="#update.contact_last#" /></td>
              <td>Attended <input type="checkbox" name="attended#currentrow#" value="yes" /></td>
              <td><input type="text" name="leads#currentrow#" size="3" /></td>
         </tr>
         </cfloop>
    </cfoutput>
    <cfloop index="i" from="1" to="#update.recordcount#">
         <cfset meeting_date = form["meeting_date#i#"]>
         <cfset contact_first = form["contact_first#i#"]>
         <cfset contact_last = form["contact_last#i#"]>
         <cfset attended = form["attended#i#"]>
         <cfset leads = form["leads#i#"]>
         <cfquery datasource="#application.Database#">
              INSERT INTO quarterly (meeting_date, contact_first, contact_last, attended, leads)
              VALUES ('#meeting_date#', '#contact_first#', '#contact_last#','#attended#',leads)
         </cfquery>
    </cfloop>

  • How can i retrieved data into the infocube from archived files

    hi,
    i have archived cube data and i have to load data into the cube from archived files.
    so now i want to find archived files and how to load data into the cube.
    thanks

    Hi.....
    Reloading archived data should be an exception rather than the general case, since data should be
    archived only if it is not needed in the database anymore. When the archived data target is serving also as a
    datamart to populate other data targets, Its recommend that you load the data to a copy of the original
    (archived) data target, and combine the two resulting data targets with a MultiProvider.
    In order to reload the data to a data target, you have to use the export DataSource of the archived data
    target. Therefore, you create an update rule based on the respective InfoSource (technical name 8<data
    target name>). You then trigger the upload either by using ‘Update ODS data in data target’ or by
    replicating the DataSources of the MYSELF source system and subsequently scheduling an InfoPackage
    for the respective InfoSource
    If you want to read the data for reporting or
    control purposes, you have to write a report, which reads data from the archive files sequentially.
    Alternatively, you can also use the Archiving Information System (AS). This tool enables you to define an
    InfoStructure, and create reports based on these InfoStructures. The InfoStructures define an index for
    the archive file data. At the moment, the archiving process in the BW system does not fill the
    InfoStructures during the archiving session automatically. This has to be performed manually when
    needed.
    Another way of displaying data from the archive file is by using the ‘Extractor checker’ (TCODE RSA3).
    Enter the name of the export DataSource of the respective data target (name of the data target preceded
    by ‘8’), and choose the archive files that are to be read. The extractor checker reads the selected archive
    files sequentially. Selection conditions can be entered for filtering but have to be entered in in internal
    format
    It will remain same in the change log table.
    Check this link :
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b32837f2-0c01-0010-68a3-c45f8443f01d
    Hope this helps you...........
    Regards,
    Debjani............

  • How can I insert data in different table dynamically?

    I have one requirement ,In these  I have transaction table in which payLoad contain data like employee record,PO record,SO record  in XML format.Now I have transfer the data from transaction table to particular table(Emp,SO,PO) dynamical ? how can I do it.. Give me your suggestion guys?? Thanks in Advance

    Hello,
    Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
    1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
    2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
    3> i made that association composite by clicking the checkbox
    4> i created 2 VO from 2 EO.
    5> put those VO in Application Module.
    6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
    Now what to do please?

  • Inserting data into a MySQL database

    Hi. I am currently working on a group project and know very little about java to be honest
    I'm trying to insert records into a local MySQL database, but I'm having trouble.
    When the application is started, a connection is made to the database, which, as far as I can tell is successful. The user adds the data through a method in a console class which then passes the parameters to 'insertCustomer' method in class DatabaseIO.
    Connection code from DatabaseIO class
    public static void openDatabase(){
    //          start by making the connection
              try{
                   //System.out.println("setting up class");
                   Class.forName("com.mysql.jdbc.Driver");
              catch(Exception e){
                   System.out.println("Driver set up error" + e);
              try{
                   url="jdbc:mysql://localhost:3306/db0611426";
                   con=DriverManager.getConnection(url,"root","");
                   System.out.println("setting up database");
                   Opened = true;
              catch (Exception e){
                   System.out.println("database connection error"+ e);
         }Add customer form
    public void addCustomer() {
                        int customerID, depositPercentage;
                        String firstName, lastName, address, phoneNumber, add;
                        boolean purchaser;
                        double budget;
                        System.out.println("\n*** Enter Customer details: ***");
                        customerID = TextInputPrompt.getInteger("Customer ID Number: ");
                        firstName = TextInputPrompt.getString("First Name: ");
                        lastName = TextInputPrompt.getString("Last Name: ");
                        address = TextInputPrompt.getString("Address: ");
                        depositPercentage = TextInputPrompt.getInteger("Deposit Percentage");
                        budget = TextInputPrompt.getDouble("Budget");
                        purchaser = TextInputPrompt.getBoolean("Purchaser?");
                        phoneNumber = TextInputPrompt.getString("Phone Number: ");
                        add = TextInputPrompt.getString("Add Customer Y/N?: ");
                        if (!add.equalsIgnoreCase("y"))
                             return;
                        customers.addCustomers(new Customer(purchaser, customerID, firstName, lastName, address, phoneNumber, depositPercentage, budget));
                        DatabaseIO.insertCustomer(purchaser, customerID, firstName, lastName, address, phoneNumber, depositPercentage, budget);
              }Constructor in customer class
    public Customer(boolean purchaser,int customerID,String firstName,String lastName,String address,String phoneNumber,int depositPercentage,double budget) {
              super();
              this.purchaser = purchaser;
              this.customerID = customerID;
              this.firstName = firstName;
              this.lastName = lastName;
              this.address = address;
              this.phoneNumber = phoneNumber;
              this.depositPercentage = depositPercentage;
              this.budget = budget;
         }Code to insert customer into table (DatabaseIO class)
    //add a new customer to the customers table
         public static void insertCustomer(boolean purchaser,int customerID,String firstName,String lastName,String address,String phoneNumber,int depositPercentage,double budget){
             String query = "INSERT customer (purchaser,customerID,firstName,lastName,address,phoneNumber,depositPercentage,budget) VALUES ('"+purchaser+"','"+customerID+"','"+firstName+"','"+lastName+"','"+address+"','"+phoneNumber+"','"+depositPercentage+"','"+budget+"')";
             System.out.println("inserting "+ query);
             try{
                  Statement stmt = con.createStatement();
                  int rs = stmt.executeUpdate(query);
             catch (Exception e){
                  System.out.println("insert failed");
        }After entering the data, the 'insert failed' is displayed in the console. Any suggestions on how to solve the problem or any ways of finding out more about the exception would be very much appreciated, thanks in advance!

    Here's how to find out more about the exception:
    catch (Exception e){
      System.out.println("insert failed");
      e.printStackTrace();
    }

Maybe you are looking for