Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-11-2010, 03:52 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Tunisia
Posts: 18
houssem is on a distinguished road
Default Iphone and databases

Good day to you all, iphone developpers

I'm developping an auditing application which must be able to read data from different types of databases ( distant on separate PC servers)

The database can be oracle, sql, Olap ....

for the iphone, I wonder if it can connect to databases, if there is something like jdbc or a kind of driver offering the connection service

I know that the iphone supports SQLlite, but can it connect to distant databases ( using an IP adress and a port number), if yes, which databases are supported?

Please, do you have any idea?
houssem is offline   Reply With Quote
Old 02-11-2010, 04:19 AM   #2 (permalink)
Daddy Cool
iPhone Dev SDK Supporter
 
MarkC's Avatar
 
Join Date: Mar 2009
Location: Yorkshire, England
Age: 100
Posts: 1,616
MarkC is on a distinguished road
Default

I think you need to use something like XML parsing or JSON. I don't believe you can pull stuff straight down from a remote DB (although I may be wrong).
MarkC is offline   Reply With Quote
Old 02-11-2010, 09:38 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Tunisia
Posts: 18
houssem is on a distinguished road
Default

Thank you Mark,
has no one ever tried this? help please
houssem is offline   Reply With Quote
Old 02-17-2010, 03:46 PM   #4 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 204
marciokoko is on a distinguished road
Default Yes you can read off a db...

Sure you can. You just need to process the data via xml or some other web service format. Im actually working on creating a service for this at the moment for both reading and writing.

I think your option is much simpler, you can dl a local copy of your sqlite file to the iphone and read it from there, if the data isnt that big.


Quote:
Originally Posted by houssem View Post
Thank you Mark,
has no one ever tried this? help please
marciokoko is offline   Reply With Quote
Old 02-17-2010, 09:48 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 147
Lars is on a distinguished road
Default

I echo Marcio statement, there isn't a native driver that is going to connect to remote databases, however, the easiest way is to create a webservice that can deliver to the phone all the data you need.

Which, depending on how generic you make your front end that will make updates very easy, as you can updates the webservice to provide more data, different layouts, new sources, etc.

But, of course more of a pain than a direct connection ~
__________________
My games:

Lars is offline   Reply With Quote
Old 02-18-2010, 08:31 AM   #6 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 204
marciokoko is on a distinguished road
Default jSON XML mySQL webservice for iphone app

Ive decided on going with jSON-XML-mySQL for my webservice for iphone app....any ideas or tutorials or pre-made code snippets welcome. ill post back on my advances and ill post the finished app on my site when im done, at Santiapps Tailor Made:.

Quote:
Originally Posted by Lars View Post
I echo Marcio statement, there isn't a native driver that is going to connect to remote databases, however, the easiest way is to create a webservice that can deliver to the phone all the data you need.

Which, depending on how generic you make your front end that will make updates very easy, as you can updates the webservice to provide more data, different layouts, new sources, etc.

But, of course more of a pain than a direct connection ~
marciokoko is offline   Reply With Quote
Old 02-18-2010, 08:49 AM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 20
nbarten is on a distinguished road
Default

In my application i have an url it connects to, and uses GET to send data with it, like 'http://mydomain.com/iphone/iphone.php?user=tester'.

The php page creates a connection with the mysql database, gets the stuff it needs, and replies to the iphone using the 'echo' command. All in JSON format of course, which the iphone app can read (with a library i found on the internet).

So yes, some kind of webservice you need which makes the connection to your databases.
nbarten is offline   Reply With Quote
Old 02-18-2010, 08:57 AM   #8 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 204
marciokoko is on a distinguished road
Default code snippet request

cool, can you give me the site you got that from? all i would have to do is create the write-to part of the xml-php code...

Quote:
Originally Posted by nbarten View Post
In my application i have an url it connects to, and uses GET to send data with it, like 'http://mydomain.com/iphone/iphone.php?user=tester'.

The php page creates a connection with the mysql database, gets the stuff it needs, and replies to the iphone using the 'echo' command. All in JSON format of course, which the iphone app can read (with a library i found on the internet).

So yes, some kind of webservice you need which makes the connection to your databases.
marciokoko is offline   Reply With Quote
Old 02-18-2010, 06:14 PM   #9 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 147
Lars is on a distinguished road
Default

Hey Marciokoko, this is a link to a website I used to talk with webservices. It shows the basics of how to create a request, response and parse the XML. Not quite php, but you can probably sort it out as needed as I imagine it's going to be very close.

Good luck

link: digital infuzion
__________________
My games:

Lars is offline   Reply With Quote
Old 02-21-2010, 03:27 AM   #10 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Seattle WA, US
Posts: 15
ALG4 is on a distinguished road
Default Raima RDM Embedded

Hi,

I may be a little late if you've already decided your solution, but I thought I'd suggest the RDM Embedded database. This will work on the iPhone (natively), and the upcoming version will allow replication from common DBMSes such as SQL Server, etc. There is a free SDK download at www.raima.com. (Note: there isn't a specific download for iPhone yet, but the Mac version works fine in the iPhone sim). There's also plenty of info there, so check it out.

Hope this helps.
__________________
ALG4 is offline   Reply With Quote
Old 10-08-2010, 04:40 AM   #11 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 7
nandhini is on a distinguished road
Default mysql database connectivity with iphone app

I have created simple login form using objective c...My next step is to create mysql database..

So far i have implemented php script for mysql database connectivity....Let me know by using xml how i can connect my objective c coding with php script..

Kindly anyone can help me to for mysql database connectivity with some sample coding.....
nandhini is offline   Reply With Quote
Old 10-09-2010, 02:34 AM   #12 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by nandhini View Post
I have created simple login form using objective c...My next step is to create mysql database..

So far i have implemented php script for mysql database connectivity....Let me know by using xml how i can connect my objective c coding with php script..

Kindly anyone can help me to for mysql database connectivity with some sample coding.....
this is a iphone dev forum, not php.

howevere see this link, should learn to you how connect to mysql database with php and give output in xml

Create XML with MySQL and PHP
Using PHP 5's DOM functions to create XML files from SQL data
__________________
dany_dev is offline   Reply With Quote
Old 10-11-2010, 04:03 AM   #13 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 7
nandhini is on a distinguished road
Default

As per our requirement we want to do the database connectivity part by using php mysql database instead of using sqlite3.If you know any links related to iPhone apps with mysql database.Kindly share with us to ensure the remote database connection.

We already developed a sample application with sqlite3 database by that we can able to store and retrieve the user details.Now we want to ensure the same using mysql database connectivity...
nandhini is offline   Reply With Quote
Old 10-11-2010, 04:35 AM   #14 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by nandhini View Post
As per our requirement we want to do the database connectivity part by using php mysql database instead of using sqlite3.If you know any links related to iPhone apps with mysql database.Kindly share with us to ensure the remote database connection.

We already developed a sample application with sqlite3 database by that we can able to store and retrieve the user details.Now we want to ensure the same using mysql database connectivity...
if you have already developed a php script that use a database, you must only use NSUrlConnection to add get or post parameters to your php script and call it.
__________________
dany_dev is offline   Reply With Quote
Old 10-12-2010, 07:22 AM   #15 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 7
nandhini is on a distinguished road
Default

This is my objective c coding for database connection


- (IBAction) login: (id) sender
{
NSString *post =[NSString stringWithFormat:@"username=%@&password=%@",userna meField.text, passwordField.text];

NSString *hostStr = @"iPhoneconnection.php?";
hostStr = [hostStr stringByAppendingStringost];
NSData *dataURL = [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];
NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];

if([serverOutput isEqualToString=="Yes"]){
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"success" message:@"You are authorized"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertsuccess show];
[alertsuccess release];

} else {
UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Fail" message:@"Invalid Access"
delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alertsuccess show];
[alertsuccess release];
}
loginButton.enabled = FALSE;
}

This is my php script

<?php
$con = mysql_connect("localhost","root","root");
if(!$con)
{
die('Could not connect: ' .mysql_error());
}
mysql_select_db("iPhoneconnection",$con);
?>
<?php
session_start();
$u = $_POST['username'];
$pw = $_POST['password'];
$check = "SELECT username, password FROM iphoneusers WHERE username='$u' AND password= '$pw'";
$login = mysql_query($check, $con) or die(mysql_error());
if (mysql_num_rows($login) == 1) {
$row = mysql_fetch_assoc($login);
$_SESSION['username']=$u;
echo'login sucess';
header("HTTP/1.1 200 OK");
}
else{
header("403 Forbidden");
}
mysql_close($con);
?>

In objective c the else part alone is getting executed..If you find any errors in the above code kindly let me know....
nandhini is offline   Reply With Quote
Reply

Bookmarks

Tags
database

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 322
6 members and 316 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:06 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0