Results 1 to 3 of 3
  1. #1
    kievari is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Default client: desktop Java app, server: Apache with php/mysql

    Hi,
    I am new to Java, and I want to develop a desktop app that downloads data from a remote Mysql database. Direct connection to the DB is forbidden by the server administrators, and php is in the middle of Java and Mysql.

    I have experience in Ajax, with xmlhttp and so on, and I wonder if the same technology is used here?

    The Java application teaches a language, say English, and it must download new words from the server with "their pronunciation" in the form of wave files (*.wav).

    I don't imagine how I can call a php function from Java desktop application :(
    Could you please explain it, or direct me to a tutorial about it, or suggest a different technology which does this job better/easier? Could you tell me the main components you consider for such a set up?

    Thank you,
    A_A

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    You can have a look at HttpURLConnection class.

    The following code retrieves contents from yahoo, you are probably looking for same kind of thing

    Java Code:
    import java.io.*;
    import java.net.*;
    
    public class NetClient{
    	public static void main(String[] arg){
    		try{
    			URL url=new URL("http://www.yahoo.com");
    			HttpURLConnection ucon=(HttpURLConnection)url.openConnection();
    			if(ucon.getResponseCode()==200){  //connection ok
    				InputStream is=ucon.getInputStream();
    				int ch=0;
    				StringBuffer sb=new StringBuffer();
    				while((ch=is.read())!=-1){
    					sb.append((char)ch);
    				}
    				System.out.println("Contents from yahoo:"+sb.toString());
    			}
    
    		}
    		catch(Exception e){
    			e.printStackTrace();
    		}
    	}
    }

  3. #3
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

Similar Threads

  1. Replies: 9
    Last Post: 01-17-2012, 09:31 AM
  2. Replies: 3
    Last Post: 10-28-2010, 03:42 PM
  3. Replies: 10
    Last Post: 10-29-2009, 09:03 PM
  4. java server-client comm
    By Manas Das in forum Networking
    Replies: 2
    Last Post: 01-28-2009, 05:58 PM
  5. Open source Email client (Desktop Based)
    By success21061985 in forum Advanced Java
    Replies: 1
    Last Post: 01-18-2009, 08:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •