File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Creating an MDB from the resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Creating an MDB from the resultset" Watch "Creating an MDB from the resultset" New topic
Author

Creating an MDB from the resultset

Surya Indukuri
Greenhorn

Joined: Dec 05, 2005
Posts: 13
I have a requirement to connect to Access Database and execute query and with the Resultset create a table in another database(MDB).
Each query resultset should be populated to appropriate tables in the .MDB.

I do not know how I can create and populate a table from the resultset.Can somebody help me?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

What do you mean when you say MDB?

As for your specific problem, you cannot usually convert the a result set directly into input to a new query, you have to break it up into multiple steps. First, perform the query, then read the results and save them in some container class or hash map. Then, construct a new set of queries based on your stored data including a single table creation statement, and execute these queries as insert statements.


My Blog: Down Home Country Coding with Scott Selikoff
Surya Indukuri
Greenhorn

Joined: Dec 05, 2005
Posts: 13
MDB is Access DataBase.

I Just need to query and store the results in a table. Is there an easy way for me to store the results into the table other than looping thru in the while and inserting rows into the table?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

Just checking, to me MDB means message driven bean but thats because I haven't used access databases in ages.

You can break it up into separate steps and do a batch import. Store the retrieved data in an array of some container class, than use the container class to build a set of import statement (or one giant batch import).

If you're are looking for some auto-magical solution that will do all this for you, you'd need a more advanced technology like JDO. In JDBC everything is done via direct SQL or possibly with the help of stored procedures.
[ January 04, 2006: Message edited by: Scott Selikoff ]
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
If you have access to Access and both MDB files, use import/link to add a symbolic link to one of the tables in the other database. You can then use a simple SQL to accomplish the task in the MDB that contains both the tables:



Cheers,


Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
 
 
subject: Creating an MDB from the resultset
 
Similar Threads
Question about J2ee architecture with an mdb and sb
Problem in Seperating Core Servlet to Database Query Java
query on an XML Database
NullPointerException on create
database