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
Highlighted
Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified
Accepted Solution

Send info from a Blackberry device to a database on a server using Java?

Hello,

 

I'm new to Blackberry development... but I now have a project to do.

I want to retrieve GPS latitude/longitude from the Blackberry and send them to a database on a server every 30 minutes.  Also, I want to be able to do that without having the user doing anything on its Blackberry (I mean,I don't want him to click somewhere every now and them).

 

I've been able to get the latitude and longitude (double) using Java.

I just don't know how to get them out of the Blackberry.

 

Can someone help?

 

Thanks

 

BTW,  I'm doing my tests on a Rogers 8310 simulator using JDE 4.2.1.

Retired
Posts: 36
Registered: ‎07-14-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Hi there,

 

The BlackBerry device needs some "gateway" to connect to the internet. This whitepaper is extremely useful in explaining all of your choices for selecting the proper gateway:

 

Managing Wireless Data Transport on BlackBerry 4 - Part 1

http://www.blackberry.com/knowledgecenterpublic/livelink.exe?func=ll&objId=832210&objAction=browse&s...

 

 

Once you have selected the gateway, then you can go ahead and use the Connector.open(url) command to create an HTTP connection to the application server (Tomcat, JBoss, .NET, etc) on the internet. The application server could then use ODBC/JDBC to store the data in the database.

 

Tariq

 

Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Thanks for your quick answer! That gives me a place to start.

Since I'm new to JDE development for the Blackberry, do you have some sample code about this?

That would help a lot.

 

Thanks again!

BlackBerry Development Advisor
Posts: 15,698
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Send info from a Blackberry device to a database on a server using Java?

I recommend you have a look at the gpsdemo samples that are included with the BlackBerry JDE.  It contains a device side and server side application.  The device side application communicates coordinates to the server side using the MDS Connection Service.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Thanks for your help!

I'm now able to send GPS coordinates from the Blackberry to a web server.

However, to do so, the user has to click on an icon manually on its Blackberry every now and then.

 

I've seen lots of examples that "get" (listen for) data from a HttpConnection.

But I'd like to push data automaticaly every 30 minutes on the Blackberry startup without having the user doing anything. Right now, with my code, I need to click on an icon on the Blackberry manually.

 

Again, I'm new to JDE Blackberry development... and I would like to know if there's a tutorial or some sample codes that does this.

 

Thanks!

BlackBerry Development Advisor
Posts: 15,698
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Send info from a Blackberry device to a database on a server using Java?

Have a look at the sample linked to below. 

 

You can also have your application start automatically by going into the project properties (right click on the project in the BlackBerry JDE and click Properties...), clicking on the Application tab and clicking off Auto-run on startup.  This would remove the requirement of a user clicking on your icon to start the application.

 

How To - Create a Background Application
Article Number: DB-00005

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800660/How_To_...

 

Or you could make use of a Timer and TimerTask instead of a thread that sleeps.

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Great! I'll have a look at this!

In your opinion, which one is best?

A thread that sleeps or a timer?

BlackBerry Development Advisor
Posts: 15,698
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Send info from a Blackberry device to a database on a server using Java?

A timer is useful if you want to schedule an application to do something at a specific time.  If you are running at a regular interval a thread with a sleep call can be simplier and could produce less garbage since a timer is creating a new thread each time it fires.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Thanks for the clear explanation.

I'll go with a thread that sleeps then, since I need to run it every 30 minutes!

 

I'm impressed by the speed and quality of your answers!

And great doc as well!

Developer
Posts: 117
Registered: ‎07-16-2008
My Device: Not Specified

Re: Send info from a Blackberry device to a database on a server using Java?

Using that sample, I made it works the way I want using a simulator!

That's so cool!

 

However, when I try it on a real device (Attach To-->Handheld - USB), the code is not executed.

Do I need to do something special to make it works on a real device?

 

I don't know anything about Blackberry device... I am just a developer... so sorry if this is a dumb question.

 

Thanks!