java connection to database

Hi,

I'm working on a sybase database.I have a table 1 in database A .I  like to take all the datas from it and insert into table 2 in database B.

I need this using java.

Any help...

Thanks,
akiles
akiles99Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

grant300Commented:
First, which Sybase product and version are you using, SQL Anywhere (ASA), Adaptive Server Enterprise (ASE), Adaptive Server IQ (ASIQ)?

Also, can you tell us what you mean by "Database A and Database B"?  Do you mean two different servers or two different databases in the same server?

Finally, depending on the database product, there are several ways to do this that do not require a program of any kind, Java or otherwise.  The simplest case is using ASE when you have two databases on the same server.  You simply do an INSERT INTO DB_B..TABLE2
SELECT * FROM DB_A.TABLE1

If they are separate servers, you have to create a remote server definition and then do a very similar operation as the one above.

You can also use a utility called Bulk Copy (BCP) to extract all the data from the one database/table and load it into the other.  It is a one line command on each end and will be many times faster than doing individual inserts with Java.

Yet another solution is to download and use an open source ETL (Extraction, Transformation, and Loading) tool called Talend.  It has an Eclipse-based GUI and generates Java programs.  If you have a bunch of this kind of stuff to do, it makes life very easy.

Regards,
Bill
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
akiles99Author Commented:
Hi,

I'm not sure about the version...

I have 2 databases in the same server....
0
grant300Commented:
Which product?  Sybase SQL Anywhere or Sybase ASE?

Do a     SELECT @@version    and see what you get.

Regards,
Bill
0
muktajindalCommented:
You can use two connection objects to connect to both the servers. Read the data from one and copy to another.
0
grant300Commented:
If you have two ASE databases on the same ASE server, you can directly move data with INSERT/SELECT statements.  Make sure you have enough log space and/or you chunk the data into reasonably sized pieces so you don't fill up the log.

Also, drop any indexes and disable any triggers on the target tables first, then move the data, then recreate the indexes and enable the triggers.

Regards,
Bill
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.