Hi Thanks for explaining how you connect. I too use PHP, so I'll give it a go.
I was wondering if anyone had seen an example of using the URI connection string in connecting to a database such as MySQL an using Java's JDBC. That way, connecting direct to the database. Cheers Graham On 25 Oct, 11:29, jbrohan <jbro...@gmail.com> wrote: > Hello > I need to look up a database in my app. I'll be doing it next week I > expect. For the moment the php just returns a constant. > <?php > $do = $_REQUEST['do']; > if ($do == "groupphone"){ > $phone=trim($_REQUEST['phone']); > $phone=str_replace(array('.','(',')','-',' ','+'),'',$phone); > if (substr($phone,0,1) == '1') $phone = substr($phone,1); // remove > '1' > echo "error"; // initial testing}elseif($do == "startgroup"){ > > echo "xyz"; > ... > > the java that does the call to the php program on the server is... > > public String callWebPage(String URLstring, String parameters){ > String s; > try { > URL updateURL = new URL(URLstring+parameters); > URLConnection conn = updateURL.openConnection(); > InputStream is = conn.getInputStream(); > BufferedInputStream bis = new BufferedInputStream(is); > ByteArrayBuffer baf = new ByteArrayBuffer(50); > Log.e("SettingsDialog", "after the call to web"); > int current = 0; > while((current = bis.read()) != -1){ > baf.append((byte)current); > } > Log.e("SettingsDialog", "back from web page"+parameters); > /* Convert the Bytes read to a String. */ > s = new String(baf.toByteArray()); > Log.e("SettingsDialog", String.format("in callWebPage = > %s ",s)); > return s; > } catch (Exception e) { > Log.e("SettingsDialog", "exception in callWebPage"); > } > return "error"; > } > > And the setup of the URLstring is...s = callWebPage(Constants.WebCall, > "?do=groupphone&phone="+s); what the php script echoed is in s. > > It seems to be very reliable. > It's worthwhile running your script from a browser first to make sure > that it works. > > Good Luck > John > > On Oct 24, 11:21 am, gmseed <gms...@gmail.com> wrote: > > > Hi > > > I'm developing an application to connect to a database on my website. > > > Does anyone know of a link to an example/tutorial in which this kind > > of operation is performed? > > > Thanks > > > Graham --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---