Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
milanvishal
Posts: 201
Registered: ‎12-17-2010
My Device: Not Specified

Copy table from one database to other database.

Hello Friends,

I want to copy one table from one database to other database.

I worked on OS 5.0.

I have used attach command to do the same,but that command didn't support in OS 5.0

So please help me by giving your suggestions.

I will appreciate all suggestions.

 

Regards & Thanks

Milan

Please use plain text.
Trusted Contributor
milanvishal
Posts: 201
Registered: ‎12-17-2010
My Device: Not Specified

Re: Copy table from one database to other database.

Hello ,

Sorry to say but is there anyone who can answer the above Question ?

 

Regards,

Milan

 

Please use plain text.
Developer
krishnanmurari
Posts: 80
Registered: ‎06-06-2011
My Device: bold 9000

Re: Copy table from one database to other database.

Hi Milan,

 

It is not possible to copy table, instead you will have to create a new table in the required database and retrieve the values from the existing database and insert it into the newly created table.

 

U will have to execute sql query in sql manager to create table, read and insert values.

 

Check this code and let me know whether it is helpfull

DB_NAME(copy data to)

DB_NAME1(To copy data from)

URI uri = URI.create(dbLocation + DB_NAME);
URI uri1 = URI.create(dbLocation1 + DB_NAME1);

 

FileConnection file;
SQLManager sql1 = null;
db = DatabaseFactory.open(uri);

 

try {
file = (FileConnection)Connector.open("file://" + dbLocation1 + DB_NAME1);

if(file.exists())
{

// See this below line the first database is called...
db1 = DatabaseFactory.open(uri1);
SQLManager sql=new SQLManager(db1);//assigning the database from which the datamust be read
sql.readfavourites();//Method created in sql manager to read the values
db1.close();

 

// See this below line the Seconddatabase is called...
sql1=new SQLManager(db);//Assigning the database to which the data must be inserted
sql1.insertfavourites();//method in sql manage to insert data.
file.delete();
file.close();
}
else
{
sql1=new SQLManager(db);
}


} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
System.out.println(" 98237948685726-----------------"+e1);
}
catch (Exception e2)
{
e2.printStackTrace();
System.out.println(" 98237948685726"+e2);
}

 

 

Let me know if the code was usefull..

 

Regards

Krishnan.

Please use plain text.
Trusted Contributor
milanvishal
Posts: 201
Registered: ‎12-17-2010
My Device: Not Specified

Re: Copy table from one database to other database.

hi,

Thanks for reply.

I have done the same thing but it takes lots of time that's why I have to post on the forum.

 

Thanks & Regards

 

Please use plain text.