Retrieving data from Microsoft Access using JDBC

I noticed that when i tried retrieving data from Microsoft access using JDBC, I realised that it was throwing SQLException when the column names were two word with spaces between them, e.g. Date Birth. But after i removed the space from the column names, my SQL queries were retrieving data. Was it because of the space in between the column names of the table?

Yeah, as far as I know having two word column names isn't allowed in SQL. There might be some way to escape it, but generally it's sensible to avoid it.

Similar Messages

  • Is there a way to retrieve data from database wihout using JDBC while using JPDK?

    Hi,
    I want to create a portlet using JPDK with extra render modes and edit/Edit defaults mode too. The detail and show renderer mode jsp's/servlets render data from database. Based on the personalized paramter, the data rendered in detail and show mode will be obtained from database.
    The articles in the PDK zip asks not to use JDBC for security vulnerability. Does that mean , I should not use JDBC to connect to db to get data. If not, what should I use ? How do I connect to database ? Is there any class which helps to connect to db without using JDBC ?
    thanks,
    Mainak

    I'm not sure what articles you are refering to, because there is no other way to access a database from a java program. Generally, security related docs tend to be a little paranoid (and so they should be), but you have to balance high security against getting the job done.
    Obviously, if using JDBC, you need to be careful about protecting your config files because they will contain connection information.

  • Retrieve data from MS Access database.

    Hi all,
    The following is part of my coding. Once I have clicked the jButton1, the jTextField1 will get the input of user and store into a variable named "bbb". After that the variable will be passed to a function as a parameter to retrieve data from MS Access database using the ResultSet method. Next, the ResultSet will be splited into many part and just the student ic will be displayed.
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
    // TODO add your handling code here:
            String bbb = jTextField1.getText(); //get input from user and store into a variable named bbb
            ResultSet codes = getCodes(bbb); //Retrieve data from database
            Code c = getCode (codes); //split the retireved date to many part
             jLabel2.setText(c.ic);  //display the student ic only
       private static ResultSet getCodes(String bbb)
            Connection con = getConnection();
            try
            Statement s = con.createStatement();
            String select = "SELECT [Student-File].* " + "FROM [Student-File] WHERE (([Student-File].[student-code])=bbb); " ;
            ResultSet rows;
            rows = s.executeQuery(select);
            return rows;
            catch (SQLException e)
                System.out.println(e.getMessage());
            return null;
    private static Code getCode (ResultSet codes)
            try
                String name = codes.getString("student-name");
                String scode = codes.getString("student-code");
                String ic = codes.getString ("student-ic");
                String add = codes.getString ("student-address");
                String phone = codes.getString ("student-phone");
              return new Code (name,scode,ic,add,phone);
            catch (SQLException e)
                System.out.println(e.getMessage());
            return null;
        private static class Code
            public String name ;
            public String scode ;
            public String ic ;
            public String add;
            public String phone;
            public Code (String name, String scode, String ic,String add,String phone)
                this.name = name;
                this.scode = scode;
                this.ic = ic;
                this.add = add;
                this.phone = phone;
    }But after I have compiled the coding above, the following error existed.
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    at testing3.getCode(testing3.java:137)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
    at testing3.jButton1ActionPerformed(testing3.java:71)
    at testing3.access$000(testing3.java:17)
    at testing3$1.actionPerformed(testing3.java:45)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
    at java.awt.Component.processMouseEvent(Component.java:5488)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
    at java.awt.Component.processEvent(Component.java:5253)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1774)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at testing3.getCode(testing3.java:137)
    at testing3.jButton1ActionPerformed(testing3.java:71)
    at testing3.access$000(testing3.java:17)
    at testing3$1.actionPerformed(testing3.java:45)
    My questions here are:
    1) Will my idea above work?
    2) Is it correct of my query statement that send to MS Access database?
    Can anyone help me?
    Thanks in advance,
    ning.

    you may try this:
    String select = "SELECT * FROM your_table_name WHERE your_column_name = '" + bbb + "'";or another approach using PreparedStatement:
    String select = "SELECT * FROM your_table_name WHERE your_column_name = ?";
    PreparedStatement ps = con.prepareStatement(select);
    ps.setString(1, "bbb");
    ResultSet rs = ps.executeQuery();hth.

  • Retrieving data from OBIEE server using ODBC

    Hello.
    I am having difficulty retrieving data from OBIEE 11g using the ODBC connection. My intention is to read OBIEE Server data via a SQL statement issued from an Oracle database using gateways.
    I have read and followed the material here:
    http://download.oracle.com/docs/cd/E14571_01/bi.1111/e16364/odbc_data_source.htm#CACBFCJA
    I have also tried this from Excel 2007, but have not succeeded:
    http://gerardnico.com/wiki/dat/obiee/import_data_from_obiee_to_excel
    I have setup a gateway in Oracle and a database link. Iknow it is connecting because when I change the password to something invalid, I get a message about not being able to connect due to username/password.
    I have taken a query from Answers (the advanced tab) and tried running it from Sql Developer. The nsqserver.log file ends up with the following Notification:
    [nQSError: 13013] Init block, 'DUAL Num (=3)', has more variables than the query select list.
    As an experiment, I am using the SampleApp, and have generated the following query in Answers:
    SELECT s_0, s_1, s_2, s_3 FROM (
    SELECT
    0 s_0,
    "A - Sample Sales"."Products"."P3 LOB" s_1,
    DESCRIPTOR_IDOF("A - Sample Sales"."Products"."P3 LOB") s_2,
    "A - Sample Sales"."Base Facts"."1- Revenue" s_3
    FROM "A - Sample Sales"
    ) djm ORDER BY 1, 2 ASC NULLS LAST
    Is there a way to issue this query from a database client like SQL Developer? I have setup a database link called obiee via gateways to the ODBC connection, and add @obiee after the table name in the above query, but get the nqs error above.
    Thanks for any help. I can provide addl info if such would be useful.
    Ari

    That would explain my difficulty. I went to the link:
    http://download.oracle.com/docs/cd/E14571_01/relnotes.1111/e10132/biee.htm#CHDIFHEE
    that describes the deprecated client. I am confused by the statement there:
    "one of the many widely available third-party ODBC/JDBC tools to satisfy previous NQClient functionality"
    My understanding of ODBC is not very strong, so please bear with me. The statement above is talking about a client tool, but there also needs to be an ODBC driver available for BI Server. I may be a bit confused between driver and client, and what piece nq handles. I don't understand the comment about third-party ODBC when it comes to the driver piece, as that must be coded for BI Server. When I go to create a new DSN, the only driver that makes sense for me to select is:
    Oracle BI Server 11g_OH<id>
    That all works fine to setup a DSN. But I am unable to connect from Excel, etc., using this DSN.
    Put more simply, should I be able to connect to BI Server via ODBC - not using the deprecated BI ODBC client, but using other clients? Is there ODBC connectivity at all in OBIEE 11g?
    Thanks,
    Ari

  • I want to convert date from Microsoft Access to Oracle.

    I want to convert date from Microsoft Access to Oracle.
    My Oracel date format is 21-Jul-2004 02:24:09 AM
    I use sqlldr in Oracle 9i Database and I
    write control file
    load data
    infile 'test.txt'
    into table test
    fields terminated by "," optionally enclosed by '"'
    trailing nullcols
    name,
    birthday
    data file 'test.txt' for input
    "dao","21-Jul-2004 02:24:09 AM"
    why did error? ORA-01843: not a valid month
    Thank.

    replace birthday with
    birthday "to_date(:birthday, 'DD-Mon-YYYY HH:MI:SS AM', 'NLS_LANGUAGE=''american''')"Of course, if your monthes are in German, then set the language to german (JUL=JUL but DEZ<>DEC)
    Regards
    Laurent

  • Trying to Import data from Microsoft Access in POWERPIVOT

    Hello,
    I am trying to import data from Microsoft Access into Powerpivot. In my Access database I have several query's.
    When I go to the Table Import Wizard in powerpivot, I only see one source table. Why can't I see the other query's?
    Thanks in advance for your help.
    Soraya

    Hello Soraya,
    Which Version of MS Excel / Power Pivot are you using? Do you try to Import from a MDB or from the new Format ACCDB? Are these common queries in MS Access or pass-through queries?
    In common it should work, if I Import from a MDB I can see & select both, tables & views (queries):
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Data from Microsoft Access ?

    Hi,
    When I deploy report that takes data from Microsoft Access, I got error: Unable to retreive object.
    How do we set the data source for this ? I tried to put the MS access file in the same folder as the published rpt file, it didn't work.
    Thanks

    There are a couple of issues here for you to look at.
    1.  How are you connecting to the database from your development machine?  If you're using an ODBC connection, that same connection must be set up on the computer where the report is deployed.  Where you're using ODBC or another connection method, your deployement computer will also need to have installed whatever drivers are necessary for connecting to Access (they aren't installed by default with Windows!)
    2.  If the database resides on the network (I know, you said it was in the same folder as the report, but you may not always be able to do that!) the user who is logged in to the machine where your app is deployed will have to have valid network access to the folder where the database is located.
    -Dell
    - A computer only does what you told it to, not what you <em>thought</em> you told it to!

  • HOW TO FILTER DATA FROM MICROSOFT ACCESS

    HOW TO FILTER DATA FROM MICROSOFT ACCESS BASED ON DATE AND TIME AND GIVE THE RESULT TO A TABLE ?
    I need some example files , can anybody please help me ?
    Solved!
    Go to Solution.

    Just be sure to get examples specific to the Jet DBMS. It is rather "idiosyncratic" when dealing with time and date values.
    One question: the timestamp is being saved in a datetime field, right?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Importing/Exporting data from Microsoft Access

    Hello to everybody!
    I have to create a management software (client-server).
    CLIENT SIDE: ClientS insert data into forms and these data are stored into a database Access (client database). Every month clients send to the server some of the data stored (data of the month!).
    SERVER SIDE: "Server man" receive from clients those data by email end need to store them into the main server database.
    Note: Data to be send have not a big dimension and, naturally, clients and server databases are identical (same structure)!
    My questions are:
    1) What is the best way to export data from database access to a file? (I imagine I need to use .XML file). Do I need to use particular package or software??
    2) What is the best way to import data from a file (maybe .XML) into a database access (of server)?? Do I need to use particular package or software??
    This is my first software of this kind.
    Please HELP ME!
    Thanks in advance, Liuk.

    1) What is the best way to export data from database
    access to a file?That depends on many things.
    (I imagine I need to use .XML
    file). NO! That's not what XML is for
    Do I need to use particular package or
    software??Again, that depends on a lot of things.
    2) What is the best way to import data from a file
    (maybe .XML) into a database access (of server)?? Do
    I need to use particular package or software??Look at Java IO packages for reading data from files. Then look at JDBC for writing data to databases. Avoid XML, you don't need it.

  • Failed to retrieve data from the database using Crystal Reports XI R2

    I am using Crystal reports XI R2 and using the Universal Web Connector (connecting to Coghead).  When I put some some of the fields from the database and run Preview I get "Failed to retrieve data from the database." .   Where is this message coming from and how can I track down what the issue is?

    Hi Jamie,
    When you are trying to Browse Data of a field it is not poping up any window menas, it is unable to interact with database and get the data from database.
    Try to create a new report using ODBC with Xtreem Sample Database.  If you get the data in your report without any error then your connector is not working / unable to pull the data into your report.
    You can find the supported platforms document in below link
    http://support.businessobjects.com/documentation/supported_platforms/xi_release2/default.asp
    Thanks,
    Sastry

  • Retrieving ESSBase data from Microsoft Access

    Hello
    Can anyone advise on how to pull data from Essbase directly into MS Access rather than via Excel?
    Thanks

    There are several ways...
    1. Report Script
    2. Date Export Calc
    I can't remember if the HAL adapter can pull from essbase and load right into access via an ODBC adapter. If so, that would be rather clean approach.
    hope this helps you get started.

  • Problem pulling data from Microsoft Access into Excel

    Using Office 2010 pro, Windows 7:
    I'm trying to pull in data from a password protected Access Database into Excel but I am having all kinds of problems..
    In Excel im using:-
    Data Link Properties> "Provider"> MS Office 12.0 Access database Engine OLE DB Provider
    "Data Source": the full path and filename to the access database
    "Enter information to log onto your server" - "use NT integrated security" is greyed out so I select username "Admin" and password <the database password>.
    When clicking on "Test connection" I get the following error message:
    "The test connection failed because of an error in initializing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user."
    Any help would be very much appreciated!
    With thanks, NECoder

    a similar issue:
    http://social.technet.microsoft.com/Forums/en-us/5779d18b-a41e-416e-9001-8bbc73670591/test-connection-failed-because-of-an-error-initializing-provider?forum=sqldataaccess

  • Send and take back data from Microsoft Access 2007

    Hi everybody,
    I wish you could help me with my application that is very urgent. I have some characters read by OCR and i want to send them to a database in Microsoft Access 2007 and compare if there is a match or not of the data i sent from labview. I want a true or false as a result of comparison in access and send this response back to labview.
    The thing is that the characters read by OCR in labview are characters from a license plate and i want to compare those in a database in Microsoft Access and this has to tell me if there is a match or not and send a response to labview to use it for letting a car enter or not to a parking lot. I dont know how to do all i have explained.
    And another question, how can i create a database in microsoft access which i could modify while i am running the application i told you before.
    Thanks a lot....
    Cristi@n
    Hola a todos,
    Espero puedan ayudarme con mi aplicación que es de suma urgencia. Tengo varios caracteres leidos de una placa vehicular mediante OCR y quisiera mandarlos a una base de datos en microsoft Access y compararlos con la base de datos de placas vehiculares para saber si esta o no en la base. Esta respuesta quisiera enviarla de nuevo al labview para mostrar si el vehiculo ingresa o no al parqueadero. Además no se si se pueda ir ingresando datos a la base de datos mientras estoy corriendo la aplicación en labview. y como hago una base de datos asi en microsoft access..
    Gracias de antemano

    Hola
    Usted puede utilizar el database connectivity toolkit
    Sigue algunos links para su consulta:
    http://sine.ni.com/nips/cds/view/p/lang/en/nid/209060
    http://digital.ni.com/public.nsf/allkb/EDA4CCE5EBE0D295862577650029D501?OpenDocument
    http://www.ni.com/pdf/manuals/371525a.pdf
    Saludos.
    Diogo
    Diogo Aparecido
    Engenheiro de Aplicação
    National Instruments Brasil

  • Upload data from microsoft access to oracle form(in data block)

    Hi all,
    Any one can help me, how we can upload data from access file to developer form(in data block).
    as
    we upload data from text file to developer form(in data block) using some packages.
    Thank's in advance

    Hi Zuhair,
    If you give details of the problems you are still having then we should be able to get SQL*Developer to work.
    However, if you don't want to use SQL*Developer then the following options are taken from note 393760.1 available in Metalink if you have access to that -
    1. Use a gateway that supports the non-Oracle database or generic connectivity if a third party ODBC driver is available to do a -
    'create Oracle_table as select from non_oracle_table@database_link'
    for each table. You would then have to manually create all the other objects (views, indexes, stored procedurs etc) and permissions etc that existed in the non-Oracle database.
    2. Use the SQL*Plus COPY command to copy data from the non-Oracle database to the
    Oracle database using a gateway or generic connectivity. The syntax is as follows:
    COPY FROM username/password@oracle_sid -
    INSERT destination_oracle_table -
    USING query;
    The following example selects all rows from the EMP table in the non-Oracle database and
    inserts them into the local Oracle EMP table:
    COPY FROM SCOTT/TIGER@ora10 -
    INSERT EMP -
    USING SELECT * FROM SCOTT.EMP@gateway;
    where "gateway" is the database link created for the gateway.
    3. Load the non-Oracle data into flat files and use SQL*Loader to put the data into Oracle tables. Again manual
    work is required for the other objects.
    4. Contact the Oracle Product Technology Services (PTS) group for assistance. See the webpage -
    http://www.oracle.com/technology/tech/migration//workbench/index_sqldev_omwb.html
    5. Use a third party migration tool. See -
    http://www.oracle.com/technology/tech/migration/isv/third_party.html
    6. Use JDBC to connect to the non-Oracle database and Java in the Oracle database. This method will work but it is not suppported by the JDBC team.
    =========
    The amount of work involved will depend on the number and size of Access tables that you want to migrate.
    Regards,
    Mike

  • How to retrieve data from MS Access

    anybody no how i can get data out of a ms access database and put on a web page? sample code very helpful...

    You can connect to MSAccess via JDBC.
    The most common approach is to create an ODBC entry in windows, and then use the JDBC-ODBC bridge that comes with java.
    http://www.easysoft.com/applications/microsoft-access/jdbc-odbc.html
    Once you have a database connection, it becomes as any other java program accessing a database.

Maybe you are looking for