×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    NOkia s60 2nd edition chinese SDK with mimer database. CLDC 1.0 MIDP 2.0.

    Hi, I am trying to develope a database application for nokia 6600 phone
    The phone supports CLDC 1.0 and MIDP 2.0.

    I decided to use Mimer mobile SQL with JDBC API.

    I am using SWTK 2.2 and installed s60 2nd edition sdk.

    Now I am successful in intalling the DB on mobile phone.
    I want to test the sample application on mimer website


    http://developer.mimer.com/howto/howto_66.htm


    1)create the database on Mimer mobile SQL 9 on desktop platform.

    2)place the project under /apps of the WTK

    3)select the s60 sdk device.

    4)build the code



    I compiled the code for s60 2nd edition sdk it compiles.The MIDlet is getting loaded on emulator.

    I have following issue
    It does not connect to DB, says could not connect to DB.

    com.mimer.jdbc.SQLException: Could not establish connection to server mimer92 on host localhost using port 1360, java.lang.SecurityException: Permission = javax.microedition.io.Connector.socket


    However, the code runs fine with other default devices provided with WTK.e.g default color phone/default gray phone.


    I added the permision for javax.microedition.io.Connector.socket in permissions tab for wireless toolkit.

    the code for the MIDlet is :



    Code:
    /**************************************************************************/
    /*  BrowsePhoneNumbers.java - Mimer MIDP example application              */
    /**************************************************************************/
    /*                                                                        */
    /*  Created by Upright Database Technology AB.                            */
    /*                                                                        */
    /*  You have a free right to use, modify, reproduce, and distribute the   */
    /*  sample files (and/or any modified version) in any way you find        */
    /*  useful, provided that you agree that Mimer Information Technology AB  */
    /*  has no warranty obligations or liability for any sample files which   */
    /*  are modified.                                                         */
    /*                                                                        */
    /**************************************************************************/
    import com.mimer.jdbc.*;
    import java.lang.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    /**
     * A simple demonstration showing how to create a database application 
     * that queries a database for telephone numbers using the Mimer SQL MIDP driver.
     */
    public class BrowsePhoneNumbers extends MIDlet {
        private Command exitCommand;
        private Command browseCommand;
        private Command backCommand;
        private Display display;
    
        /**
         * This midlet contains two screens. One for entering queries, and one for displaying 
         * query results.
         */
        private MainForm mainForm;
        private ResultList resultList;
    
        /**
         * If the midlet becomes paused, this maintains which screen was active
         * when it was paused.
         */
        private Displayable currentDisplayable;
    
        /**
         * The Mimer datasource object. This object specifies connection properties such
         * as database server, database name and so forth.
         */
        private MimerDataSource mds;
    
        public BrowsePhoneNumbers() {
    	display = Display.getDisplay(this);
    	exitCommand = new Command("Exit", Command.EXIT, 1);
    	browseCommand = new Command("Browse", Command.ITEM, 1);
    	backCommand = new Command("Back", Command.BACK, 1);
            currentDisplayable = mainForm = new MainForm();
    	mds = new MimerDataSource();
    	mds.setServerName("localhost");
    	mds.setDatabaseName("mimer92");
    	mds.setUser("sysadm");
    	mds.setPassword("sysadm");
        }
    
        // Start the MIDlet by creating the TextBox and
        // associating the exit command and listener.
        public void startApp() {
        	System.out.println( "Gonna create Alert..app" );
    	    display.setCurrent(currentDisplayable);
    	    Alert a = new Alert( "My alert" );
    	    display.setCurrent(a);
    	     
        }
    
        /**
         * Pause is a no-op because there are no background activities to speak about.
         * If there is a database connection open, the pending work is to be carried
         * out on the server. In the meanwhile, this midlet is suspended
         * until resumed. When the midlet resumes, any result from the server may be ready
         * at that time.
         */
        public void pauseApp() { 
        
    	currentDisplayable = display.getCurrent();
        }
    
        // Destroy must cleanup everything not handled
        // by the garbage collector.
        // In this case there is nothing to cleanup.
        public void destroyApp(boolean unconditional) { }
    
        public void exitApplication() {
    	destroyApp(false);
    	notifyDestroyed();
        }
    
        /**
         * The main form where the user enters is search values.
         *
         * The user will have two options from this form. Either quit the application
         * or start a search query from the values entered in the form.
         */
        class MainForm extends Form implements CommandListener {
    	private TextField namField,phnField;
    
    	MainForm() {
    	    super("Phone dictionary");
    	    namField = new TextField("Name", "", 25, TextField.ANY);
    	    phnField = new TextField("Phone", "", 15, TextField.ANY);
    	    this.append(namField);
    	    this.append(phnField);
    
    	    this.addCommand(exitCommand);
    	    this.addCommand(browseCommand);
    	    this.setCommandListener(this);
    	}
    
    	public void commandAction(Command c, Displayable s) {
    	    if (c == exitCommand) {
    		exitApplication();
    	    }
    	    if (c == browseCommand) {
    		resultList = new ResultList(this,namField.getString(),phnField.getString());
    		display.setCurrent(resultList);
    	    }
    	}
        }
    
        /**
         * The ResultList class implements a list showing a number of telephone numbers.
         * It is designed to run in a separate thread, which queries the database and
         * then dies.
         */
        class ResultList extends List implements Runnable,CommandListener {
    	/* When the user press "back", this indicates which Displayable to activate. 
    	 * Supplied with the constructor. */
    	private Displayable backDisplayable;
    
    	/* A name or a phone number to search for. Supplied with the constructor. */
    	private String nameSearch,phonSearch;
    
    	/**
    	 * This constructor also starts a separate thread to populate this List
    	 * with phone number entries from the database.
    	 *
    	 * @param back The Displayable to activate when the user press "back".
    	 * @param nameSearch A name of parts of a name to search for in the telephone number database.
    	 * @param phonSearch A telephone number of parts thereor to search for in the telephone number database.
    	 */
    	ResultList(Displayable back,String nameSearch,String phonSearch) {
    	    super("Found numbers", Choice.IMPLICIT);
    	    backDisplayable = back;
    	    this.nameSearch = nameSearch;
    	    this.phonSearch = phonSearch;
    	    this.addCommand(exitCommand);
    	    this.addCommand(backCommand);
    	    this.setCommandListener(this);
    	    (new Thread(this)).start();
    	}
    
    	/**
    	 * Accepts command actions.
    	 */
    	public void commandAction(Command c, Displayable s) {
    	    if (c == exitCommand) {
    		exitApplication();
    	    }
    	    if (c == backCommand) {
    		display.setCurrent(backDisplayable);
    	    }
    	}
    
    	/**
    	 * Each ResultSet object runs the run-method once.
    	 * The run()-method connects to the database, queries it, and
    	 * populates the List with what the query returned.
    	 */
    	public void run()
    	{
    	    System.out.println( "Gonna create Alert.." );
         
    	    Connection con;
    	    /* Specifies the maximum number of telephone numbers to display. */
    	    int entriesToDisplay=20;
    	    /* If this application is to be run against a mobile server, such as a Symbian OS server
    	     * or a development server running in Mobile mode, the EXECUTE STATEMENT facility _must_
    	     * be used. Otherwise, the latter SQL-statement may be used directly.
    	     */
    	    String sql = "execute statement PHNQRY";
    //	    String sql = "select trim(NAM),trim(PHN) "+
    //		         "from PHONE "+
    //                       "where upper(trim(NAM)) like '%'||coalesce(upper(?),'')||'%' "+
    //		         "and upper(trim(PHN)) like '%'||coalesce(upper(?),'')||'%'"; 
    
    
    	    try {
    	    //Alert a = new Alert( "My alert" );
    	    //showAlert( a );
    	    System.out.println( "Gonna create Alert..1" );
         
    		con = mds.getConnection();
    		try {
    		    PreparedStatement ps = con.prepareStatement(sql);
    		    try {
    			/* By setting the fetch size we instruct the database server to send us
    			 * result set rows (=telephone numbers) in batches. Since we have decided 
    			 * to display only <entriesToDisplay> telephone numbers we request only that
    			 * rows from the server. This is essential for query performance and also
    			 * to avoid transferring more data than necessary from the server.
    			 */
    			ps.setFetchSize(entriesToDisplay);
    			ps.setString(1,nameSearch);
    			ps.setString(2,phonSearch);
    			ps.execute();
    			ResultSet rs = ps.getResultSet();
    			try {
    			    while (rs.next() && entriesToDisplay-->0) {
    				append(rs.getString(1)+" "+rs.getString(2),null);
    			    }
    			    if (entriesToDisplay==0) 
    				append("More was found...",null);
    			} finally {
    			    rs.close();
    			    rs = null;  // Make sure the ResultSet object can be GC:d as soon as possible.
    			}
    		    } finally {
    			ps.close();
    			ps = null;
    		    }
    		} finally {
    		    con.close();
    		    con = null;
    		}
    	    } catch (SQLException se) {
    	    	System.out.println(se+"exception");
    		append(se.getMessage(),null);
    	    }
    	}
        }
    }
    Last edited by 86.coolguy@gmail.com; 2010-02-24 at 19:07. Reason: java.lang.SecurityException

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    4

    Re: NOkia s60 2nd edition chinese SDK with mimer database. CLDC 1.0 MIDP 2.0.

    I tried things and googled it.
    One need to request permission of the perticular class(in my case it is javax.microedition.io.Connector.socket) in jad file.
    To run midlet on emulator ,it should be installed first.
    After installation, one need to change the application permission from app. manager, setting network access to ask for 1st time or always allowed (if available) will solve the problem.
    checkpermission() function can be handy in these kinda situations.

Similar Threads

  1. is S60 2nd FP3 MIDP SDK for nokia 6600 development
    By macnux in forum Mobile Java Tools & SDKs
    Replies: 2
    Last Post: 2009-03-15, 22:29
  2. Icons in s60
    By drizzt6 in forum Mobile Java General
    Replies: 5
    Last Post: 2009-03-06, 09:32
  3. Series 60Series 60 MIDP Concept SDK Beta 0.2 Linux bug?
    By kauppi in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2003-04-07, 09:05
  4. Almost all tools (S60 MIDP SDK B0.1, Nokia S60 SDK Symbian OS v0.3) Crashes
    By alexandershalamov in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-07-03, 13:44

Posting Permissions

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