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
Developer
Posts: 192
Registered: ‎01-12-2010
My Device: Bold
My Carrier: ZAIN

SQL Server connection in BB

Dear,
i was going through some posts for sql server connection: this what i found.

There's no JDBC in the BlackBerry API. In short, your options are:

 

1. Setup a web service that exposes the SQL statements you wish to run from the phone. Have the phone make HTTP calls instead of SQL.

2. Port the JDBC driver for your database to the BlackBerry (and the java.sql package).

 

 

Can anybody please post some sample codes for above two examples.

 

rgds

Nadir

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQL Server connection in BB

I am not aware of any attempt to port JDBC to the BlackBerry.  So I would not expect to get a response to your request for sample code for this.

 

Also you will probably already find sample code for your first option around.  Your option of 'tunneling' SQL statements through http is a variation on many questions that have been asked on this forum.  Have quick search for SQL. 

 

In fact there is nothing special in this from the BlackBerry perspective, it just does http calls and receives the response.  But you may find this communication is the hardest part of the process, so I suggest you start by investigating doing just that.  There is sample code supplied with the JDE, or you could work through the Network Sticky Thread here:

http://supportforums.blackberry.com/t5/Java-Development/Connecting-your-BlackBerry-http-and-socket-c...

Also, there are a number of blogs out there with sample http connection code, I particularly like the sample supplied by versatilemonkey. 

 

From experience dealing with SQL data, you have to have some intelligence at the Server end and the Blackberry end to process this sort of request.  There are performance, integrity, consistency and size issues when shipping data like this to and from the BlackBerry. 

 

Have you considered Sybase's product.  It may well do what you need it to do (it has sync facilities for example) already. 

Developer
Posts: 192
Registered: ‎01-12-2010
My Device: Bold
My Carrier: ZAIN

Re: SQL Server connection in BB

Dear Peter,

thanks for the post.

 

since your an expert can you please show me with an example as iam a newbie on BB and after 2 yrs touching java.

may be you developed any application with database connectivity.

 

I have downloaded the sybase anywhere but it requires a key but still they didnt email me .

 

may be you can provide me with one.

 

Any help is highly appreciated!!!

rgds

Nadir

 

 

Developer
Posts: 192
Registered: ‎01-12-2010
My Device: Bold
My Carrier: ZAIN

Re: SQL Server connection in BB

Dear Peter,

 

has anyone connected to any database ..

i have seen one application doing such connection DBviewer plus..

 

 

rgds

Nadir

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQL Server connection in BB

I've used two approaches to getting SQL data - the Server end of this code does connect to SQL data.

 

a) Used a http POST to format a request, the request was picked up some Php processing, which extract that data and sent it back in a format the BlackBerry code understood. 

 

b) Used a socket connection to send a request, the request was picked up by a socket server and the data was sent back, again in a format the Blackberry processing understood (different to (a).

 

Note that the fact that the data was SQL is actually irrelevant, the BlackBerry asked for some information in a way that the Server code understood, and the Server code responded with the data in a way that the BlackBerry understood.  And that is what you have to do.  There is, as far as I know, no other option.

 

So you don't need SQL sample code, you just need connection sample code.  You need to write the Server end and BlackBerry end to process data on whatever pipe you choose. 

Developer
Posts: 192
Registered: ‎01-12-2010
My Device: Bold
My Carrier: ZAIN

Re: SQL Server connection in BB

Dear Peter,

its been really nice talking and get guidance from you.

 

i have passed the stage of connection now i have used ASP.NET for connection to the database and then i am reading those responses in JAVA..

 

now what i decided is to get the data in xml from ASP.NET and then read it in java.

 

is there any help or example available by which i can read xml data.

 

 

rgds

Nadir

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: SQL Server connection in BB

How To - Use the XML Parser
Article Number: DB-00394
http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800599/How_To_...

In addition, there are a few posts on this forum that talk about processing downlaoded XML data. 

Contributor
Posts: 28
Registered: ‎11-13-2012
My Device: none
My Carrier: 27768965251

Re: SQL Server connection in BB

This is exactly what I want to achieve, but you didn't answer me in this way, I already have the server side up and running, I just need to know how to transform it to blackberry code as you call it.

Please could you be more clear on this?
Developer
Posts: 17,019
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: SQL Server connection in BB

please open an own thread for your question.
the BB cannot connect to a sql server directly, you have to either expose the sql server using a webservice (or similar, for example json) or write a middleware to do the same.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 28
Registered: ‎11-13-2012
My Device: none
My Carrier: 27768965251

Re: SQL Server connection in BB

I am exposing the content of the sql content via a php web service...I just want to know, how must I construct the data so that I can use it....instead of it looking like this...

 

this is xml format, but I'm assuming json will be better

sample.jpg