×

Discussion Board

Results 1 to 2 of 2

Thread: plz help

  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    108

    plz help

    I have a midlet(Mobile Application) connected to a servlet(jsp)[WebApplication], which works fine

    I now copy-pasted both pieces of code onto a new MobileApplication, and a new WebApplication(and changed the name of the midlet classes respectively), but the jsp code isn't working for some reason and I can't seem to figure out why! I've been trying to understand the problem for a while now..
    the previous jsp page was called 'ConnectJspToMysql.jsp', and the new one is called 'ConnectToBaby.jsp'

    Please have a look at the code below:
    PHP Code:
    <%@ page import="java.sql.*" %>
    <%@ 
    page import="java.io.*" %>

    <%
          try {
              
    /* Create string of connection url within specified format with machine
      name, port number and database name.*/
              
    String connectionURL "jdbc:mysql://localhost:3306/db_audiology";

              
    // declare a connection by using Connection interface
              
    Connection connection null;

              
    /* declare object of Statement interface that is used for executing sql
      statements. */
              
    Statement statement null;

              
    // declare a resultset that uses as a table for output data from tha table.
              
    ResultSet rs null;

              
    // Load JBBC driver "com.mysql.jdbc.Driver"
              
    Class.forName("com.mysql.jdbc.Driver").newInstance();

              
    /* Create a connection by using getConnection() method that takes parameters
              of string type connection url, user name and password to connect to database.*/
              
    connection DriverManager.getConnection(connectionURL"root""");

              
    /* createStatement() is used for create statement object that is used for
      sending sql statements to the specified database. */
              
    statement connection.createStatement();

              
    // sql query to retrieve values from the secified table.
              
    String QueryString "SELECT * from baby";
              
    rs statement.executeQuery(QueryString);
              
    String delimiter = new String();

    %>

        <%
        while (
    rs.next()) {
        %>
            <% 
    delimiter =  rs.getString(1)+"|";
            
    delimiter =  delimiter rs.getString(2)+"|";
            
    delimiter =  delimiter rs.getString(3)+"|";
            
    delimiter =  delimiter rs.getString(4)+"|";
            
    delimiter =  delimiter +rs.getString(5)+"|";
            %>
          <%=
    delimiter %>
        <%   }    %>


        <%
        
    // close all the connections.
        
    rs.close();
        
    statement.close();
        
    connection.close();
      } catch (
    Exception ex) {
        %>

            <%
                 
    out.println("Unable to connect to database.");
               }
            %> 
    It displays: 'Unable to connect to database', when I run the jsp page.

    Please help

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: plz help

    the issue is with this line:
    connection = DriverManager.getConnection(connectionURL, "root", "");

    Check the username and password for your db and also connectionURL.

    thanks,
    ~Amitabh

Similar Threads

  1. need help for NOKIA 5300 plz help me
    By indian1792 in forum General Development Questions
    Replies: 1
    Last Post: 2009-08-05, 04:24
  2. Replies: 5
    Last Post: 2008-10-09, 05:38
  3. Grid: help PLZ (Urgent)
    By diptivs in forum Symbian
    Replies: 3
    Last Post: 2008-01-01, 03:49
  4. Vibration Problem (urgent plz..)
    By valiant123 in forum Mobile Java General
    Replies: 1
    Last Post: 2007-06-14, 07:37
  5. yes plz. thanks
    By jump_912 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-11-21, 17:11

Posting Permissions

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