Unable to copy table in same Database

I m using jdbc:odbc bridge to connect to MS access database. i am trying to create a table by copying data from another table in same database. the code is
Statement stmt = mycon.createStatement();
String query = "create table " + temp1 + " as select * from " + temp2;
stmt.executeUpdate(query);
But java is throwing exception as:
java.sql.SQLException: [Microsoft][ODBC Microsoft Acces Driver] Syntax error in
CREATE TABLE statement.
Simple create and select are working fine. Is there something like MS Access doesnt support such queries?
Thanx for help
Viney

Hi Viney_yadav,
First a general suggestion: The error message you got states that is a SQL syntax error. This tells you that you should try running the SQL that is failing directly through Access and correct the syntax problem there. That will help you verify the SQL syntax and avoid any complications related to Java.
And now some specific help (cut/paste from a previous life): Different DBMS's handle the SELECT INTO... differently. SELECT INTO... in Microsoft Access actually creates a new table. If the table already exists (in Access) then you would use the INSERT INTO..SELECT... statement.
EXAMPLE to create and populate a new table in Access (sorry didn't test this):
select temp2.* into temp1 from temp2

Similar Messages

  • Connection with tables of same database

    i want to access two tables of same database using JDBC.
    how can i do it in MS Access
    i have to create two connection one for each or two statement for same connection

    i want to access two tables of same database using
    JDBC.
    how can i do it in MS Access
    i have to create two connection one for each or two
    Yo don't need to create two connections to access two tables.
    Single Database connection is enough.
    Try the following pseudo code to access two tables
    1. get Database Connection
    2. create statement with query that is for table 1
    3.execute it and close the statement .
    4. again create the statement with query that is for table 2
    5. execute it and close the statement .
    6. close the connection.
    hope it will clear you,
    nvseenu
    statement for same connection,

  • To copy table from one database to another

    hai,
    I will be really pleased if someone can me tell me that how can i copy table from one database to another. I am having two databases.
    Gursimran

    You can Also do
    ++ Create a database link on the TARGET to SOURCE
    CREATE PUBLIC DATABASE LINK <<DBLNK_NAME>> CONNECT TO <<USER>> IDENTIFIED BY <<PASSOWORD>> USING '<<TNS_NAME>>';
    ++ And copy as below
    CREATE TABLE EMP AS SELECT * FROM EMP@DBLNK_NAME;

  • How to check relation between two tables in same database

    How to check relation between two tables in same database using Oracle SQL developer. Version 2.1.1.64

    Hi,
    Try this,
    SELECT   cons.owner AS child_owner, cons.table_name AS child_table,
             cons.constraint_name constaint_name,
             cons.constraint_type constraint_type, col.owner parent_owner,
             col.table_name parent_table, col.column_name column_name
        FROM dba_cons_columns col, dba_constraints cons
       WHERE cons.r_owner = col.owner
         AND cons.r_constraint_name = col.constraint_name
         AND col.owner = 'MY_USER'
    ORDER BY child_table;Thanks,
    Shankar

  • Copy table from one database to another database

    Hi,
    I am new to SQL and I have a question on copying a table.
    QUE: copy one table with huge data(around 60millions of rows) from one database to another database(have to create a new table) in the same server. 

    Hi ,
    By mistake ,I understood you want to copy on different server .
    I have rectify above.On same server we can copy Table in many way ;
    As I mentioned Above you can use ;
    select * into [Destination Database].[dbo].[NewTableName] from [SourceDatabase].[dbo].[Category]
    Second;
    select * into [Destination Database].[dbo].[NewTableName] from [SourceDatabase].[dbo].[Category] Where 1=2
    Insert into [Destination Database].[dbo].[NewTableName]
    select * from [SourceDatabase].[dbo].[Category]
    Thanks

  • Schema Copy/replicate in Same database....

    Hello - I have a requirement to copy a schema in same database - with different name. What will be my best options other than export/import.
    Schema name: PROD
    Schema Size: 120GB
    Tablespace: All data of PROD is in PROD_D tablespace only
    New Schema name will be: NPROD
    Thanks in advance

    hi,
    If you're worried about the dump size, you may generate it and get a 20Gb size file...
    follow instructions from link Compressed dump
    ... if your schema has only tables, you may use CTAS
    Regards
    Ignacio
    http://oracledisect.blogspot.com

  • Updatable Materialized View and Master Table on same database

    Hi all,
    My first question - Is it possible to have an Updatable Materialized View and the associated Master Table located on the same database?
    This is the requirement scenario:
    One unique database D exists.
    A is a batch table. Only inserts are allowed on Table A.
    M is an updatable materialized view on Table A (Master). Only updates are allowed on M (no insert or delete).
    Requirement is to push updates/changes from M to A periodically and then get the new inserted records from A into M via a refresh.
    Is this possible? What other approaches are applicable here?

    John,
    My question is related to the implementation and setup of the environment as explained in the above example. How can I achieve this considering that I have created an updatable m-view?
    If possible, how do I push changes made to an updatable m-view back to it's master table when/before I execute DBMS_MVIEW.REFRESH on the m-view? What is the procedure to do this if both table and mview exist on the same database? Do I need to create master groups, materialized view refresh groups, etc.?
    One more thing.. Is there a way to retain changes to the m-view during refresh? In this case, only newly inserted/updated records in the associated table would get inserted into m-view. Whereas changes made to m-view records would stay as-is.
    Hope my question is directed well. Thanks for your help.
    - Ankit

  • DB Adapters inserting data into 2 diff tables of same database giving issue

    Hello,
    I am using Oracle soa suite 11g BPEL.
    I need to insert data in 4 different tables of same Oracle database with the requirement of rollback all data if error occurs anywhere.
    I have configured the DB adapater as XA enabled on console .
    In code:-
    I am using 2 DBAdapters to insert data one by one in 2 diff tables of same DB (using INSERT ONLY operations). Before each invoke activity i am using a transformation activity to prepare the input variable of the DBAdapter.
    When i run this code i get below error:-
    Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute Failed Exception. insert failed. Descriptor name: [DBINS_DIANA.XxontPoiHdrsIface]. Caused by java.sql.BatchUpdateException: ORA-02049: timeout: distributed transaction waiting for lock . ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
    If i use a wait activity between the 2 invokes i get the data inserted fine , but that means the transactions between inserts would be committed which i want to be rollback fully in case of any errors.
    Can anyone have a clue what is wrong here?
    Thanks
    Shivani

    Hi Anagha,
    Have a look at these links:
    /people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30
    http://help.sap.com/saphelp_nw04/helpdata/en/b0/676b3c255b1475e10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/2b/d5653fd1d3b81ae10000000a114084/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/95/bb623c6369f454e10000000a114084/frameset.htm
    Regards,
    Chandra

  • How to manipulate data over two tables in same database.

    hi, i am not a profficient java programmer, i was trying to copy filtered data from one table to another table.
    i was trying to use
    public static Connection getConnection() throws Exception {
         Driver d = (Driver)Class.forName
             ("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
         Connection c = DriverManager.getConnection
             ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=stuff.mdb");
         return c;
    and then
        theConn = myConnection.getConnection();
          ResultSet rs;
          Statement stmt;
          String sql;
          stmt = theConn.createStatement();
          sql =  "SELECT * FROM shisab, myhisab WHERE shisab.Who_Bought ='ron'";
               rs = stmt.executeQuery(sql);
               while (rs.next()) {
                System.out.println("date:"+rs.getString("shisab.Date"));                 
          rs.close();--------------------------------------
    it does not show anything! in the output! i tried many things but i thing it is not supporting my multiple table syntax , i.e.: table1,table2 in teh from clause.
    please help!
    i just need to filter stuff from the shisab table and write the filtered data into
    the myhisab table.

    Your problem isn't in the Java code, it's your SQL code...
    Your statement, as submitted, is an improperly formed multi-table select, where you never joined the second table. That won't work.
    You need to look into the INSERT INTO statement. The exact syntax of your statement will depend on whether or not both tables contain the exact same column names, etc. A generic example based on what you have might look like:
    INSERT INTO myhisab SELECT * FROM shisab WHERE Who_Bought = 'ron'HTH

  • Insert records from user form to multiple tables in same database

    Hi Experts, I need your help. I have a form that has multiple text fields that I need to insert the records to their each respective table. For example: The first name field needs to go the the name table, address goes to a seperate table, phone goes to a seperate table and so on.
    Is this possible to do?
    Thanks Much
    Sham

    The same for ASP, JSP or PHP.  Just the code syntax is different for each language.  Are you using MySQL, Access or ?
    In any case, create the three recordsets on the database and use insert queries.  If you don't know what one is, google insert query and you will see the syntax. 
    Here is a good example out on the web
    http://www.stardeveloper.com/articles/display.html?article=2000032601&page=1
    In your case you would get the values for the inserts from the form data and only need to open the database connection once.
    Good luck.
    Walt
    B & B Photography

  • Best way to copy table from one database to any other database

    I need to write an application to perform database table copy from one kind of database to another kind of database.
    I just wrote a simple JDBC program which essentially does the something like below:
    PreparedStatement statement = null;
    ResultSet rs = null;
    try
    System.out.println("insertSQL:" + insertSQL.toString());      
    statement = target.prepareStatement(insertSQL.toString());
    System.out.println("selectSQL:" + selectSQL.toString());
    rs = source.executeQuery(selectSQL.toString());
    int rows = 0;
    while (rs.next())
    rows++;
    for (int i = 1; i <= columns.size(); i++)
    statement.setString(i, rs.getString(i));
    statement.execute();
    System.out.println("Copied " + rows + " rows.");
    But problem with this one is that it takes lot of time( more than 60 mins) for 100k records transfer. Would there be any faster way to do this?
    TIA...

    Thanks...
    I am using now batch update mechanism and set the fetchsize of resultSet cursor.
    Now I need to copy a table with almost 10 million records to the target database. My program works fine but it takes more than 3 hours.
    I am copying from Postgres table to MS SQL server table.
    Is there any other way or more better appraoch to make this more faster?
    TIA..

  • Three Tables from same database

    What is the most effective way to simultaniously display
    three seperate dynamically generated tables all from the same data
    table?

    Could the OP possibly mean displaying 3 HTML tables based on
    data from a single database table?
    Phil

  • Unable to import table using SOA database adapter in Jdev

    hi all,
    I am learning soa 11g development by myself which is quite exciting stuff.
    I am trying to build a simple flow to access database so I have dropped a database adapter in composite.xml and trying to configure the adapter.
    I have successfully tested the database connection within the adapter configuration wizard and can list the tables as well. But when I am selecting a table to import then I don't see any table imported in Step-5.
    It doesn't show me any error. I have tried with other tables and also with other databases but can't import the tables.
    Any advice will be appreciated.
    Oracle SOA Version11.1.1.4.0
    JDeveloper Version 11.1.1.6.0
    Thanks,
    Raj

    Hi Raj,
    You have to select the required tables and move it to the blank area on right side of your selection window by clicking the arrow button.
    cheers

  • Unable to import table using SOA database adapter in jdeveloper

    I am trying to build a simple flow to access database so I have dropped a database adapter in composite.xml and trying to configure the adapter.
    I have successfully tested the database connection within the adapter configuration wizard and can view the tables as well.
    But when I am selecting a table to import then I don't see any table imported in Step-5.
    It doesn't show me any error. I have tried with other tables and also with other databases but can't import the tables
    i have selected the table using the right arrow to right side and then clicked "OK". But the table hasn't come-up and it still says "No tables imported" in Step 5. I am trying to import from oracle database using oracle jdbc.
    am doing Perform an operation(Select query) on a table
    Regards,
    Kishor M

    Thread moved form Japanese SOA Suite.

  • What is te best way to copy a table from a database to another?

    Hello friends:
    I have two databases: an Access database and an Oracle database. I must copy the data from al tables from the Access database to the oracle database. The tables in the both databases are equal (number of columns, type, etc).
    I read an resultset from acces (select * from table1) and I insert every row in the Oracle database with an while loop (while (r.next)...). It works fine when there are a few rows, but I have a table with over 200000 rows, and when I'm copying the row number 30.000, the system goes very slow...
    How can I copy tables from a database to another more quickly?
    Thanks!

    CASE #1
    The most efficient method would be to copy all the rows from Microsoft Access and write them to a text file using Access's native interface (not JDBC), then use Oracle's SQL Loader utility (not JDBC) to insert the data.
    You can insert 200,000 rows of 80 bytes each in 30 seconds or less even on a modest Oracle system using SQL Loader. The extract from Access is very dependent on the size of the CPU and the available memory.
    Hint 1: Avoid explicit or implict network traffic.
    Hint 2: Extract and load from local drives rather than networked or shared drives on other services
    Please note that this is done for efficiency of load, but has issues related to error checking, and operational scripting.
    Anything else you do or use will be slower than the method (above).
    CASE #2
    If you want to integrate this into a single JDBC program which will provide better operational management of the process, then you can simply connect to both databases in your Java program, then read the rows one at a time from Access, insert them using the Batch mechanism of JDBC to Oracle. You will also want to set the FetchSize in Oracle to a larger value then the default (i.e set it to 100 vs 10).
    Hint #3 You may want to look into alternative JDBC drivers for accessing MS Access, rather than the JDBC-ODBC bridge which is not optimized for MS Access. You may also want to consider using the OCI8 driver from Oracle rather than the thin driver. Both provide Type 4 functionality but I have heard (not experienced) that the OCI8 driver is better for managing batch style of processing like yours
    Good luck!
    Joel

Maybe you are looking for

  • Open hub for Inventory data

    Experts, We have a requirement where we need to push out Inventory data from BW to third party systems. We have a daily cube and monthly snapshot cube implemented. Now, there are fields that the third party systems require including Movement type. Th

  • How do I save user drawn graphics to a jpeg? (This code doesn't work).

    As the title says, I have the code that I think should work but cannot see what is wrong with it: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; impo

  • Need to log in with a new Apple id

    NNeed to log in with a new Apple id

  • Problem in uploading HR master Data from excel

    Hello When I am  uploading HR master data using excel , I get the error "Error in info type 0006 and emp no 00000016 with msg id 00 no. 055 msg Fill in all required entry fields " I have filled in   the following fields for  infotype 0006:- SUBTY ='1

  • Tokens & Cached Mode

    Does anyone know what happens if you try and use a RuleCreate token while in Cached Mode? Does it cache it and create it properly once its reconnected? Thanks, Shane