Insert in Java via Microsoft Access

Hello People
I need insert into DataBase datas with app in Java and DataBase Microsoft Access. How insert in Microsoft Access with app Java? Witch the Syntax of the SQL for Microsoft Access with app Java?
Thanks
Richard
Java/Oracle Programmer

http://java.sun.com/docs/books/tutorial/jdbc/index.html

Similar Messages

  • "java ODBC Microsoft Access Driver Syntax error (missing operator) in query

    Hi I am new to java and I am getting this error message when using java to access and insert data into an MS Access database.
    "java ODBC Microsoft Access Driver Syntax error (missing operator) in query expression"
    The commands are
    String insertCommand = "INSERT into MetricOutput(A1,A,DRR,DeRR,RE,WDRR,WDeRR,WRE,ARF,SRF,HRF,WARF,WSRF,WHRF,SDC,WSDC,MAR,WMAR,H1,H11,H2,H21,cluster) "+
                             "VALUES("+comMappedCount+","+stdCount+","+DRR+","+DeRR+","+RE+","+WDRR+","+WDeRR+","+WRE+","+ARF+","+SRF+","+HRF+","+WARF+","+WSRF+","+WHRF+","+SDC+","+WSDC+","+MAR+","+WMAR+","+H1+","+H11+","+H2+","+H21+",+array)";

    "VALUES("+comMappedCount+","+stdCount+","+DRR+","+DeRR+","+RE+","+WDRR+","+WDeRR+","+WRE+","+ARF+","+SRF+","+HRF+","+WARF+","+WSRF+","+WHRF+","+SDC+","+WSDC+","+MAR+","+WMAR+","+H1+","+H11+","+H2+","+H21+",+array)";After looking at your post in the editor, I see what your real query looks like.  You realize that ",+array[i])" is part of the query, right?  And not actually looking at your Java array?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java visit microsoft access database question

    I want to visit microsoft access database,like follows:
    String dirverClass="sun.jdbc.odbc.JdbcOdbcDriver"; String url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\apache-tomcat-5.5.27\\webapps\\Test\\db.mdb"; String content=""; try{   Class.forName(dirverClass);   Connection conn=DriverManager.getConnection(url);   Statement stmt = conn.createStatement();   String sql="select * from mytab"; ResultSet rs = stmt.executeQuery(sql); while(rs.next()){       content=rs.getString("zd1"); }
    My question is whether I must install microsoft access database?
    Thanks

    Far as I know and have been able to determine a MS Access ODBC driver comes with every windows install going back to about windows 98. Might be 95 as well.
    I haven't looked at some of the more exotic ones like the 64 bit versions nor the mobile versions.

  • Can Java executes Microsoft Access Macro?

    Is there any way to run a Macro of Access database from Java? How to
    do it if so?
    I searched the internet, I have not found an answer yet. It seems
    there is no way. true or false?
    We have a lot of statistic charts generated by Macros of either Access
    database or Excel and want to put on the web so that user can view the
    charts by a click from anywhere. Our web applications are developed
    in JSP and on Tomcat.
    Any suggestions are appreciated.
    Thanks

    **MAJOR SPAMMING SCUM BAG ALERT**
    I was puzzled in that you asked a SQL Server question in one post and then in another thread asked a Oracle related question... and then I noticed you had cross posted one of your questions at JavaRanch and I was more annoyed....
    and then I found this....
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=10&t=002447
    You sir -> Michael Byrd -> are scum sucking dirtbag.
    To quickly explain. Mr. Byrd posts his messages (which he copies wholesale from other posters) so that he can get better google caching for the website listed in his profile.
    This is such scummy behaviour I don't even know what to say. Other than basically everyone that has ever helped you had totally wasted their time.
    You are scum. Your company is scum. I hope you rot in hell.

  • Insert into Microsoft access 2010 Database on sharepoint using OLEDB

    Hi,
    want to insert data into a microsoft access web db using oledb object. but the i am unable to open the database.
        dbLoc = "http://XXXX.com/project/design/Test_Web_DB
        Dim strConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & dbLoc
        Try
                con = New OleDb.OleDbConnection(strConnection)
                If con.State = ConnectionState.Closed Then con.Open()
        Catch ex As OleDbException
               MsgBox("OleDbException: Unable to Open DB")
        End Try
    it always go to the exception. is there any problem with the above code??

    Hey Bala,
    Browsing the link (as shown below) on the browser doesnt open the DB.
    http://XXXX.com/project/design/Test_Web_DB.accdb
    Instead, without ".accdb" works.
    my requirement is something like below, please recommend your suggestion
    1. i have a DB on access 2010, which gets updated on regular basis (currently db is on common location) by different VB.net application client my the network
    2. i want to create various reports out of the data and want them visible available on sharepoint.
    please help
    -Manash

  • An error occured when connecting java with Ms Access

    Hello Everybody
    I am a new developer in java and want to connect java with Microsoft Access
    i am using JCreator LE
    My code is to insert 3 records for 3 members and then save them in DB and retrieve the information
    Here is the code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "Information";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( connURL ,"","");
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception e) {
                System.out.println("An error Occurred in Connecting with the DB " );
    }and the error is
    Beginning Connection
    Connection done successfully
    An error Occurred in Connecting with the DB
    it didn't insert information in the DB

    Well, thank u i have traced the error and fx it
    but
    how to modify the code and keep the user entering 3 values and search for the entered values??
    Here is the correct code
    import java.sql.*;
    public class Project3 {
        public static void main(String[] args) {
             try {
                  System.out.println("Beginning Connection");
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                String accessFileName = "jdbc:odbc:Project";
                String connURL = "jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ="+accessFileName+".mdb;PWD=";
                Connection con = DriverManager.getConnection( accessFileName);
                Statement stmt = con.createStatement();
                System.out.println("Connection done successfully");
                stmt.execute("Create table Member(Name String,ID Integer)");
                stmt.execute("insert into Member values ('Joe','1234')");
                stmt.execute(" select * from Member");
                ResultSet rs=stmt.getResultSet();
                if (rs != null)
                     while (rs.next()){
                          System.out.println("Name: "+rs.getString("Name")+ "ID: " + rs.getString("ID"));
                stmt.close();
                con.close();
                catch (Exception err) {err.printStackTrace();}
    }

  • Better reports than microsoft access?

    Hey guys,
    I'm creating a system that combines java with Microsoft Access through JDBC. I'm looking to generate reports based on the information saved to the database but the reports in Access are not very nice :( Any advice on a tool that I could use that would create better looking reports??

    Yo Philly*, why don't youse connect Excel to Access wida macro. Udderwise youse can connect Excel to anudder database system.
    *I am assuming you are from Fluffya or the DelVal and not simply a fan of Philadelphia sports teams.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Can not Insert data to Microsoft Access successfully

    I am using Microsoft Access database, and trying to insert some data into a table with a "while" loop, but every time, the last row can not be inserted although the return value of the "executeUpdate()" is 1, can anyone tell what's wrong with that? thank you very much

    http://forums.java.sun.com/thread.jsp?forum=48&thread=147704
    Sounds like it may be the same "glitch"
    Jamie

  • Java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]

    Hello. I'm trying to do an INSERT into an MS Access 2002 database, and this is throwing:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] '' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.
    The INSERT is pretty straight forward:
    INSERT INTO Nodes (ID, Name, IP, DateAdded) values ("m22", "Colt,Frankfurt,GR", "213.61.48.52", "2003-02-06")
    ID is a TEXT field of length 3 and it is the key (table is currently empty)
    Name is a TEXT field of length 50.
    IP is a TEXT field of length 16.
    DateAdded is TEXT field of length 10.
    I tried putting dummy data into the table and doing a SELECT, and that worked without a problem.
    Can anyone tell me what is or might be causing this? Thanks in advance!!!
    - john ferguson, kansas city

    Okay, I fixed this.
    The fix was to change the double quotes (") to single quotes (') inside the VALUES part of the statement.
    So it went from:
    INSERT INTO Nodes (ID, Name, IP, DateAdded) values ("m22", "Colt,Frankfurt,GR", "213.61.48.52", "2003-02-06")
    to:
    INSERT INTO Nodes (ID, Name, IP, DateAdded) values ('m22', 'Colt,Frankfurt,GR', '213.61.48.52', '2003-02-06')
    and now it works fine.

  • Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]

    I am having a problem inserting/updateing date field of MS Access database with JDBC. I have tried several solutions. Serveral Field formats in the db and several methods with java. I will post my most recent attempt. I can read from the database I just can't write the date to the db, though I can write to any other field with a different datatype.
    Please don't bash me for using MS Access, it is my only option.
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
    if (rs != null){
    while ( rs.next() ) {
    Date tDate;
              //Timestamp tDate;
              //String tDate;
    tDate = rs.getDate("Week");
              //tDate = rs.getTimestamp("Week");
              //tDate = rs.getString("Week");
              java.sql.Date sqlDate = new java.sql.Date( Date.getTime() );
              //java.sql.Timestamp sqlDate = new java.sql.Timestamp( tDate.getTime()
    System.out.println("Date: " + tDate );
    //System.out.println("Date: " + sqlDate );
    //System.out.println("Date: " + rs.getDate ("Date") );
    // 2004-03-24 00:00:00.0 this is Timestamp output
         Cpu.moveToInsertRow();
    Cpu.updateDate("Date_Col",sqlDate );
         //Cpu.updateDate("Date_Col",tDate );
         //Cpu.updateTimestamp("Date_Col", sqlDate);
         Cpu.insertRow();
    Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
    Please help..........

    I can insert a new row and add all the fields (includeing date (as string)), but I have to use SQL statements. I cannot get the result set functions to work.
    I can retieve a rs just fine and print all the contents of the rs.
    My problem is with rs.updateRow();
    my code is below,
    public class Cpu_Load_Total_Cpu{
    public static void main(String[] args){
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String filename = "C:/dev/SHC/Cpu_Java/CFS_Health.mdb";
    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
    database+= filename.trim() + ";DriverID=22;READONLY=false}";
    Connection con = DriverManager.getConnection( database ,"","");
    Statement stmt = con.createStatement(
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
         ResultSet Cpu = stmt.executeQuery("SELECT * FROM Cpu");
    if (Cpu != null){
         while ( Cpu.next() ) {
                   int tUsr, tSys, tWio, tIdle, tTotal_Cpu;
                   tUsr = Cpu.getInt("Usr");
                   tSys = Cpu.getInt("Sys");
                   tWio = Cpu.getInt("Wio");
                   tIdle = 100 - (tSys + tUsr + tWio);
                   tTotal_Cpu = tSys + tUsr + tWio;
                   Cpu.updateLong(8, tTotal_Cpu);
    //or Cpu.updateLong("Total_Cpu", tTotal_Cpu);
    // I get the same error as the post above
    // when I include the Cpu.updateRow(); call
                   Cpu.updateRow();
    // when excluded everything else runs fine, but
    // the db is not updated
    // as stated, everything prints to the screen or pipe when
    // updateRow is excluded
                   System.out.println("Usr: " + tUsr );
                   System.out.println("Sys: " + tSys );
                   System.out.println("Wio: " + tWio);
                   System.out.println("Total_Cpu: " + tTotal_Cpu);
                        con.commit();
                   stmt.close();
                   con.close();
    catch (Exception e) {
    System.out.println("Error: " + e);
    }

  • How to insert date in microsoft access

    dears
    i want to insert date in a table which is in microsoft access.
    and also use the date in where clause.
    the col. name is mydate and the data type is Date/Time
    when i try to insert the date as a string it cannot.
    '"+date.getText().trim()+"'
    what can i do plz help me.

    Right, use java.sql.PreparedStatement and its setDate()/setTimestamp() methods. It'll escape the java.sql.Date and java.sql.Timestamp properly for you. I use PreparedStatement all the time to escape dates, times, and strings correctly in a portable way.

  • Executing Microsoft access macros using java

    Hi Everyone,
    I hava an application in microsoft access,in which many macros which extract data are there.I want to know is there anyway that I can execute the macro written in microsoft access using java.
    Can anyone please answer the above.
    Regards,
    Rakesh.

    rakbha wrote:
    I hava an application in microsoft access,in which many macros which extract data are there.I want to know is there anyway that I can execute the macro written in microsoft access using java.
    I am rather certain that that is not possible via the ODBC driver and thus not possible via JDBC.
    There is certainly an OS API that will allow that but accessing those is not a standard part of the Java API so it would require a JNI solution (yours or someone else's) or an application that allows that access.

  • Insert Time and Date into Microsoft Access from Lookout

    I have an SQLExec running to export data to Microsoft Access - I would like to get A) A time stamp also to insert and B) A time stamp with out / and : -- I have found it impossible (from my limited knowledge) to do any of these things.
    Dose anyone have a very basic SQL Statement that might guide me on my way?
    Thanks!

    Oracle stores date and time in a DATE column; it all depends on how you have your insert statement. The last insert I specified the date and time
    ex.
    insert into test_date values(1,sysdate);
    insert into test_date values(2,sysdate-10.9);
    insert into test_date values(3,sysdate-8.098 );
    insert into test_date values(4,sysdate-5.11 );
    insert into test_date values(5, trunc(sysdate));
    INSERT into test_date values(6, to_date('01-JAN-2004 19:30', 'DD-MON-YYYY HH24:MI') );
    select * from test_date ;
    ID DDATE
      1 25-FEB-04
      3 17-FEB-04
      4 20-FEB-04
      5 25-FEB-04
      2 14-FEB-04
      6 01-JAN-04I don't see the time because the NLS_DATE_FORMAT is set to DD-MON-YY, but if I
    Select id, to_char( ddate , 'DD-MON-YYYY HH24:MI:SS AM') from test_date;
    ID TO_CHAR(DDATE,'DD-MO
    1 25-FEB-2004 06:57:02
    3 17-FEB-2004 04:37:05
    4 20-FEB-2004 04:20:02
    5 25-FEB-2004 00:00:00
    2 14-FEB-2004 09:24:50
    6 01-JAN-2004 19:30:00

  • INSERT statement in Java and MS Access

    Hi all,
    can anyone please tell me how to insert data to an MS Access table using JSP i tried INSERT statement of java but it is getting errors saying INSERT statement is wrong. I have no idea about MS access insert statement. i am totally tired of this. Please someone help me.

    Hello,
    MS Sql can cause problems where it goes off standard, however I dont think insert is any different.
    INSERT INTO table_name (column1, column2) VALUES (variable1, variable2)
    Make sure your table and column names are exactly right, Java is case sensitive, so make sure the case is correct also.
    The other common error is if you have a required field in the database that is not populated by your program, so, if for instance there was a column3 in the table for the above example, which was a required field, the sql would fail as there is no data being entered for column3.

  • Known problems or limits regarding accessing BDB with Java via JNI

    Hi,
    we are currently in an evalutation phase and are planning to use BDB (C|JE) as back-end for a queueing system. This system is written in Java. One key requirement is high availability of the data hold in the back-end. We need the guarantee, that no data is lost, e.g. data added after checkpoints. The throughput is expected to be quite high (> 10.000.000 records hold within one single BDB-environment (we would use n parallel BDB-envs inside the service).
    So i'm wondering about using JE or DB... The former doesn't provide a replication system but is a 100%-pure Java implementation, the latter is written in C and accessed via JNI, which adds some overhead and maybe instability issues but comes with an integrated replication system. JE would require us to develop an in-application replication system or to use a DFS for HA or something like that.
    Are there any known issues regarding using DB with Java via JNI? Or any other hints?
    TIA,
    Dirk

    Silly me, I forgot to mention that a null return value means that an exception was thrown so you should get that and print the value (although I suspect it will be "class not found").

Maybe you are looking for

  • Moved to the US, Itunes no longer works! Help!

    I am a US citizen who was living in Switzerland. I have now moved back. My Swiss credit cards have been cancelled/expired so I can no longer buy music off of itunes...yet I don't know how to change my billing information to say I now live in the US.

  • Elements 12 Install problems

    I purchased Elements 12 from the trial version and have been trying to download and install for a week now.  I have encountered errors about the files being downloaded to seperate areas to files being unable to be unzipped and am currently getting ha

  • Problem adding large images to albums

    What I want to do is view my images large, one at a time, and add them to various albums as I go. This used to work fine in v6 but now, zoom in Max and you can no longer select photos. It seems you can only select images once they are get about 320px

  • Theme Customisation

    Hi there, As a complete newbie, I have started to customise a theme (No4) for use within my organisation. I have tried following the Twiki (http://wiki.shellprompt.net/bin/view/Apex/ThemeTips) but am confused at the beginning and was hoping if someon

  • How to perform Update operation in Ios using Odata Services

    Hello,       I want to do PUT(update) operation on odataservice... I am using followin code to get the proper Entry property to update SDMODataEntry * entry1=((SDMODataEntry *)[ArraySelectedCell objectAtIndex:0]);     SDMODataPropertyValueObject* obj