• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

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
0
akiles99
Asked:
akiles99
  • 3
1 Solution
 
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
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now