Inserting a record into Access database

Hi guys i am having problem with the insertion of a record in to a Access database!!!!
It is not given any exceptions or errors but simply does not insert it!!!
Here is my code!!
import java.sql.*;
class access
public static void main(String a[])
// Set default values for the command line args\par
Connection connection; // Connection to the database
Statement statement; // Statement object for queries
String user = "";
String password = "";
String url = "jdbc:odbc:db1";
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try
Class.forName(driver); // Load the driver
connection = DriverManager.getConnection(url, user, password);
if(a.length !=0)
PreparedStatement ps = connection.prepareStatement("insert into search(Orgname,Website) values(?,?)");
ps.setString(1,a[0]);     
ps.setString(2,a[1]);
int res = ps.executeUpdate();
System.out.println("i am in" + " the output result no ="+res );
ps.close();
catch(ClassNotFoundException cnfe)
System.err.println(cnfe); // Driver not found
catch(SQLException sqle)
System.err.println(sqle); // error connection to database
-DK

I'm not sure, but I think, linking your code against a library is considered as "using", not "deriving", since you don't change the library itself.
It should not matter, whether you link staticly or dynamicly or only ship a file to use it with a program (like reading an image).
Otherwise: how could anyone "use" a static library without linking his code to it?
If - like you described - some features are "too low level" for your taste (I would feel similiar), I can only tell my experience:
With InterBase you have a GPL'd DBMS which is available in fully mainted shape. You can download the executables and use it like a commercial DBMS - no touch with libraries or the sources, if you don't want.
IBConsole is a tool that can be compared with MS SQLServer's Enterprise Manager, I think!
InterClient/InterServer offers a JDBC type 3 driver.
There are also some ODBC drivers for it at the market.
This is real Open Source!
What do you want more?

Similar Messages

  • Can you use ESB to insert multiple records into a Database

    We have an XML file that has a Parent/Child relationship.
    In situation 1 we have a single parent record in the xml file. We can insert the record into the database successfully.
    In situation 2 we have a parent and a an associated child record. By using a filter expression to identify the existence of the child record we can route to the first DB Adapter to insert the parent then to the second DB Adapter to insert the child.
    Is this final scenario logical and also possible.
    Situation 3 we have multiple child records associated to a single parent. So we would first insert the parent record then insert all the child records.
    Thanks

    I use PL/SQL for this if you are using Oracle.
    Have a look at this post, it is for AQ but the concept can be used for PL/SQL
    Re: Can I pass a pl/sql table as a parameter from a database adaptor
    I will send you an example
    cheers
    James

  • Inserting multiple records into a database from a table

    I have a dynamic table with rows upto 10. i am trying to insert all the records in these rows into a database ( msaccess)
    table name: Table1 ( in my form )
    Database table : movies_comments ( as posted in stefan's forums ).
    table columns: username, movieid, comments
    i am using the following code.
    Database.ExecSQL() function is as posted in stefcamerons forums.
    var tlength = xfa.resolveNode("form1.#subform[0].Table1.Row1[*]").length;
    xfa.host.messageBox("tlength is :" +tlength);
    for ( var i = 1; i <= tlength; i++)
    var username = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].user_name").rawValue;
    var movieID = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].movie_id").rawValue;
    var commentS = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].comment_").rawValue;
    Database.ExecSQL("INSERT INTO movie_comments (username, movieId, comment) VALUES ('username','movieID', 'commentS');");
    i am trying to insert multiple records using the code above. But i am getting error
    GeneralError: Operation failed.
    XFAObject.resolveNode:1:XFA:form1[0]:#subform[0]:Button1[0]:click
    SOM expression returned list when single result was expected
    suggest me an alternate way to insert multiple records from a table into a database.
    thank Q

    figured it out. I changed the ...OR (alternative names = colname) in the recordset to ...OR (alternative names LIKE %colname%). Works like a charm now- the result of a good night's sleep.

  • Somehow ejbCreate method of an Entity EJB is not inserting a record into the database. I'm using BMP and calling the Entity bean method from a servlet. I'm using NAS 4.0 sp5 on Win 2k.

    Also if I call the insert query from within the servlet it works fine. I have disabled global transactions. Am I missing something out ? Please
    any help would be greatly appreciated.

    May be your servlet is not able to lookup the EJB. You can use some print statements and see whether lookup ok or not.
    Just a guess.
    Plese get back, if any queries.
    Thanks,
    Rakesh.

  • Inserting multiple records in to database table using webdynpro abap

    Hi all,
    I have created a username inputfield,a button and a table
    with one coloumn.
    If i enter  names in the input field then the values should be
    displayed in that table.
    Even i have got the answer i am not able to insert
    the values in to database(ztable) table.
    i.e. only one value(1st) was inserted the second value was
    not inserted ....
    so kindly send me the coding to insert multiple records
    into the database table......
    by,
    ranjith

    hi Ranjith,
    If you want to insert multiple records from the webdynpro view table to database table then try the following code.
    DATA lo_nd_tablenode TYPE REF TO if_wd_context_node.
      DATA lo_el_tablenode TYPE REF TO if_wd_context_element.
      DATA ls_tablenode TYPE wd_this->element_tablenode.
      DATA it_tablenode LIKE STANDARD TABLE OF ls_tablenode.
      navigate from <CONTEXT> to <tablenode> via lead selection
      lo_nd_tablenode = wd_context->get_child_node( name = wd_this->wdctx_tablenode ).
      get element via lead selection
      lo_el_tablenode = lo_nd_tablenode->get_element(  ).
      get all declared attributes
      lo_nd_tablenode->get_static_attributes_table(
      IMPORTING
        table = it_tablenode ).
    MODIFY databasetablename FROM TABLE  it_tablenode.
    here it_tablenode is the internal table which holds the value from webdynpro view..
    Regards,
    Shamila.

  • Inserting new records into database table at runtime

    Hi all ,
    How to insert new records into database table at runtime on click update?
    Thanks.

    Hi Sasikala,
    Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
    1) Obtain the reference of your context node.
    2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
    3) Use your normal ABAP logic to update the database table with the data from your internal table
    In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
    data: node_sflight           type ref to if_wd_context_node,
            elem_sflight           type ref to if_wd_context_element,
            lt_elements            type WDR_CONTEXT_ELEMENT_SET,
           stru_sflight           type if_main=>element_sflight_node,
           it_flights             type if_main=>elements_sflight_node.
    "   navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
        node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE'  ).
       lt_elements = node_sflight->get_elements( ).
    "   Get all the rows from the table for saving on to the database
        loop at lt_elements into elem_sflight.
          elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
          append stru_sflight to it_flights.
        endloop.
    " Finally save the entries on to the database
        modify ZSFLIGHT99 from table it_flights.
        if sy-subrc eq 0.
    endif.
    However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
    Regards,
    Uday

  • Insert multiple records into database through internal table

    Hi
      please help me how to insert multiple records into database through internal table

    Hi,
    Welcome to SCN.
    Press F1 on INSERT statement and you will teh syntax as well the docu for the same.

  • Insert multiple rows of records into the database

    The codes below allow me to insert a row of record into the database. How would I changed these to insert multiple rows at once? Please help!
    String sql = "INSERT INTO EMPLOYEES" +
    "(First_Name, Last_Name, Title, Phone) " +
    " VALUES " +
    PreparedStatement statement = conn.prepareStatement(sql);
    statement.setObject (1, First_Name);
    statement.setObject (2, Last_Name);
    statement.setObject (3, Title);
    statement.setObject (4, Phone);
    boolean returnValue = statement.execute();

    Hi mystiqueX,
    As wmolosho has suggested in his answer to this very same question that you also posted to the JavaServer Pages forum, you can create a batch of inserts and perform them using the "executeBatch()" method. I will use Craig's sample code to demonstrate:
    (Note that this code is untested!)
    conn.setAutoCommit(false);
    PreparedStatement statement = conn.prepareStatement(sql);
    // assume you have an array of objects here
    for (int i = 0; i < data.length; i++) {
      statement.setString(1, data<i>.getFirstName());
      statement.setString(2, data<i>.getLastName());
      statement.setString(3, data<i>.getTitle());
      statement.setString(4, data<i>.getPhone());
      statement.addBatch();
    statement.executeBatch();
    conn.commit();If you are not familiar with it, allow me to suggest looking at the Making Batch Updates lesson on the Java Tutorial.
    Hope it helps.
    Good Luck,
    Avi.

  • Inserting into a record into a database

    When i cal the following method (only part of the method) the method executes fine with any exceptions or errors however the company which is meant to be added to the database does not get added. Does anybody know what the problem could be?
    else
    int uniqueIDPortfolio = Variables.getSelectedPortfolio ();
         System.out.println(uniqueIDPortfolio);
         queryString = "INSERT INTO CompanyDetails VALUES(";
         queryString += uniqueIDPortfolio + ",";
         queryString += "'" + symbol + "',";
         queryString += "'" + value00 + "',";
         queryString += "'" + value01 + "',";
         queryString += "'" + value02 + "',";
         queryString += "'" + value03 + "',";
         queryString += "'" + value04 + "',";
         queryString += "'" + value06 + "',";
         queryString += "'" + value07 + "',";
         queryString += "'" + value08 + "',";
         queryString += "'" + shares + "',"; // no of shares
         queryString += "'" + price + "',"; // total price paid
         queryString += "'" + value09 + "',";
         queryString += "'" + value10 + "',";
         queryString += "'" + value11 + "',";
         queryString += "'" + value12 + "',";
         queryString += "'" + value13 + "',";
         queryString += "'" + value14 + "',";
         queryString += "'" + value15 + "',";
         queryString += "'" + value16 + "',";
         queryString += "'" + value17 + "',";
         queryString += "'" + value18 + "',";
         queryString += "'" + value19 + "',";
         queryString += "'" + value20 + "',";
         queryString += "0,";
         queryString += "0,";
         queryString += "False,";
         queryString += "4";
         queryString += ")";
    System.out.println(queryString);
         // insert the company into the database. Data needs to be added to the CompanyDetails table
         myStatement.executeUpdate(queryString);
    Thank You for your assistance

    I have changed it so that it is no longer a method.what does this have to with anything?
    I now get a SQL exception. ah-ha!
    could you perhaps copy and paste the exception here so that we might be enlightened as to what exactly is going wrong. a stack trace might be good.
    Can i use MS Access to check
    if the sql statement is correct? If so how would i do
    this?yes. when you print out the query to the console (the command or DOS window) copy and paste it into the access query tool.
    to open up the access SQL query thing do the following.
    open the database in access.
    go to the queries tab.
    select new.
    select design view.
    close the select table prompt thingy.
    now go to the top menu (File, Edit, etc) and select view.
    select SQL view.
    paste the query in there.
    execute the query by clicking the exclamation point.
    voila.

  • Different methods involved in insertion of records into the table

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production)
    Oracle Database 10g Release 10.2.0.1.0 - Production
    i have parameters like emp_code(optional) and year(mandatory field-four digit year).
    Based on the parameter i have to get the details from one table and those records should be inserted into other table along with additions columns(by hardcoding the additional columns).
    To acheive this i am planning to get a cursor by selecting the necessay fields from the table passing the parameters in the where clause of the cursor.
    by looping through the cursor i will insert the records into the other table.
    here the thing is the data is going to be huge (since year is the parameter).
    so is my approach leads to the performance issue.
    i heard that there are different method of insetions,
    can anybody suggest me the better way(peformance wise) other than what i have mentioned (if you are aware of)..
    Thanks..

    This is not really a Forms issue, so you'd better go to the sql and pl/sql forum. Here, this question has been asked many times: how do I insert large volumes of data in a table?
    insert into ...
    select ....
    or CTAS (create table as select ....)
    by looping through the cursor i will insert the records into the other table.That is really the worst idea. If you can do it in sql (insert into ... select ...) DON'T do it in pl/sql.

  • Insert multiple records into Oracle using Java

    Hi,
    Has anyone tried to insert multiple records into an Oracle table from Java? I have my data in a Java collection.Can I send a Java Collection to an Oracle Package as a PL/SQL Table Type? My problem is I dont want to instantiate a CallableStatement object everytime I do an insert. Instead I want to do that only once and then insert multiple records in one operation.
    Any suggestions will be appreciated,
    Thanks,
    Alex

    Hi Mensa,
    I went thru the code example in your book in chapter 8 (downloaded it from OTN). It looks like the java code for "public class myPLSQLIndexTab" might be a java stored procedure stored in the oracle database?
    Pardon my ignorance because I've never worked on java code in the oracle database itself but how would I call such a program outside the oracle database? For example say I have a batch job that downloads data from a webservice and that batch job is written in java and its sitting on a batch server somewhere on the network. But the java program that inserts data into the database is sitting in the oracle database (also somewhere in the same network). How can the java code sitting on the batch server talk to the java code sitting on the oracle server? Is it the same as calling a pl/sql package using CallableStatement?
    Thanks
    Alex

  • Inserting a record into an Excel

    Hello! Everyone, I am now trying to use Excel as a database, however, I could not insert any records into a spreadsheet but I could read the data from it. Please help...here is the code..
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import java.util.*;
    public class InteractWithExcel {
         static final String DRIVER_NAME = "sun.jdbc.odbc.JdbcOdbcDriver";
         static final String DATABASE_URL = "jdbc:odbc:EXCELJDBCTest; READONLY=0";
         public static void main(String[] args) {
              try {
                   Class.forName(DRIVER_NAME);
                   Connection conn = null;
                   conn = DriverManager.getConnection(DATABASE_URL);
                   Statement stmt = conn.createStatement();
                   stmt.executeUpdate("insert into [Sheet1$] values ('ABC', 68)");
                   ResultSet rs = /*stmt.executeQuery("select sum(Population) from [Sheet1$]");
                        stmt.executeQuery("select State,Population from [Sheet1$]");
                   while (rs.next()) {
                        String state = rs.getString(1);
                        int population = rs.getInt(2);
                        System.out.println(state + " - " + population);
                   rs.close();
                   stmt.close();
              } catch (ClassNotFoundException cnfe) {
                   System.err.println("ClassNotFoundException Was Thrown");
                   cnfe.printStackTrace();
              } catch (SQLException sqle) {
                   System.err.println("SQLException Was Thrown");
                   sqle.printStackTrace();
    }

    The code is somehow workable....
    The problem is that...
    1) a record could only be added only if I open the corresponding excel file
    2) the record is added to the end of the spreadsheet...
    e.g. there three records in the spreadsheet, namely 1, 2, 3,
    if I open the file and then run the java programme, the new record will be added to 4...
    then I deleted record 4 manually by opening the excel file and then delete,
    now, if I run the java programme again, the new record will be added to 5....but not the empty space 4...
    how come???
    Please help!

  • Insert multiple records into a table(Oracle 9i) from a single PHP statement

    How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
    From what all I've found, the statement below would work if I were using MySQL:
         insert into scen
         (indx,share,expire,pitch,curve,surface,call)
         values
         (81202, 28, 171, .27, 0, 0, 'C' ),
         (81204, 28, 501, .25, 0, 0, 'C' ),
         (81203, 17, 35, .222, 0, 0, 'C' ),
         (81202, 28, 171, .27, 2, 0, 'C' ),
         (81204, 28, 501, .20, 0, 1, 'C' ),
         (81203, 28, 135, .22, 1, 0, 'C' )
    The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
    Thank you,
    Will

    You could look at the INSERT ALL statement found in the documentation here:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
    My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
    The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
    HTH.

  • Issue of inserting greek characters into Oracle database using ICAN505

    Hi All,
    We are currently facing an issue of inserting greek characters into Oracle database using ICAN505.
    We receive a file containing greek characters.The values from the file should be inserted into the database.We are reading the file using file OTD with default encoding.
    The file can contain english characters too other than greek characters.
    The database NLS_CHARACTERSET is AL32UTF8.
    When I insert using an insert statement directly ,the values get inserted properly into the DB table.
    Inserting the same values using code results in improper characters getting inserted into the table in the database.
    Please help....
    Thanks in advance !!

    Globalization forum?
    Globalization Support
    It works for SQL Developer, which does not depend on NLS_LANG, so I suspect a problem with your NLS settings.

  • Insert date time into oracle database from jsp

    pls tell me ,from jsp how can I insert datetime values into oracle database .I am using oracle 9i .here is codethat i have tried
    html--code
    <select name="date">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="month">
    <option selected>dd</option>
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    </select>
    <select name="year">
    <option selected>dd</option>
    <option>2004</option>
    <option>2005</option>
    <option>2006</option>
    <option>2007</option>
    </select>
    here the jsp code
    <% date= request.getParameter("date"); %>
    <% month= request.getParameter("month"); %>
    <% year= request.getParameter("year"); %>
    try
    { Class.forName("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException exception)
    try
         Connection connection = null;
         out.println("connectiong the database");
    connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:orcsid","scott","tiger");
    out.println("connection getted");
         int rows = 0;
         String query_2 = "insert into mrdetails values(?)";
         String dob = date+month+year;
         prepstat = connection.prepareStatement(query_2);
         prepstat.setTimestamp(4,dob);
         rows = prepstat.executeUpdate();
         out.println("data updated");
    catch (Exception exception3)
    out.println("Exception raised"+exception3.toString());
    }

    To insert date values into a database, you should use java.sql.Date. If it also has a time component, then java.sql.TimeStamp.
    Your use of prepared statements is good.
    You just need to convert the parameters into a date.
    One way to do this is using java.text.SimpleDateFormat.
    int rows = 0;
    String query_2 = "insert into mrdetails values(?)";
    String dob = date+"/" + month+ "/" + year;
    SimpleDateFormat sdf = new SImpleDateFormat("dd/MM/yyyy");
    java.util.Date javaDate = sdf.parse(dob);
    java.sql.Date sqlDate = new java.sql.Date(javaDate .getTime);
    prepstat = connection.prepareStatement(query_2);
    prepstat.setTimestamp(4,sqlDate);
    rows = prepstat.executeUpdate();
    out.println("data updated");Cheers,
    evnafets

Maybe you are looking for

  • Put iPod in disc mode -- unplugged it??

    I plugged my ipod in to my computer in disk mode, to charge and i was loading...so then I left it while it was charging...came back about an hour later and computer was asleep so I unplugged my ipod to see if it was charged...thing was i forgot to ej

  • DNG SDK not working on Mac (Leopard)

    Hi, I am writing a program to create dng files via the latest adobe dng sdk. I follow the same basic recipe as outlined in the example dng_validate code. On a Windows PC, the created thumbnails and previews appear just fine. However, the same code on

  • Servlet output not displayed properly in Internet Explorer

    Hi All, I'm developing a servlet which uploads a file. After the servlet parses the request body, it stores the file contents as a binary string in the database. While displaying the contents of the attached file, the IE(Internet Explorer) is ignorin

  • GR Service Doc Item Catory "D" not transfered to BW using 2lis_02_sgr

    Hi Friends, I have a problem using Standard Datasource (2LIS_02_SGR). When I extract data from R/3 system, some POs are not captured to BW but my bw loading everything working fine in Production. When I cross check with R/3 system, POs which are unde

  • Air Fortress Gateway and 4402 WLC

    All, I'm in the process of a demo/protoype using the cisco lightweight products (4402 controllers w/ 1240 LAP), and using Air Fortress gateway for Layer 2 authentication...I have 3 lightweight AP's associated with the controller (running in Layer 3 m