-1

How to retrieve or display data on html page from db2 by sql adapter in ibm worklight?

What are the codes for these?

  1. How to Display data in a text box?
  2. How to Display data in a label?
  3. How to Display data in a drop down box?
  4. How to select check box?
    like automatically getting data from db2 for example Interests:Technology,Science,etc. Now the user can update/change data and save.
  5. How to select radio/option button? like automatically getting data from db2 for example Gender:Male or Female. Now the user can update/change data and save.

like in jsp. Is the codes are same in android hybrid apps development or not?

<body>
    <center><h2>Your Account Details</h2></center>
    <%
    String usertype="general";
    String email=(String)session.getAttribute("email");
    String pwd=(String)session.getAttribute("pwd");
    String sex=new String();
    Connection con=null;

    try
                   {
        if(email==null)
            out.println("<center>Please Login to view your account!!!");
                   //MS ACCESS
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    con=DriverManager.getConnection("jdbc:odbc:dsn1");

                    PreparedStatement pst=null;

                    pst=con.prepareStatement("select * from user1 where usertype=? and email=? and pwd=?");
                    //"select * from user1 where usertype='"+usertype+"' and email = '"+email+"' and pwd='"+pwd+"'"
                    synchronized(pst)
                        {
                        pst.setString(1, usertype);
                        pst.setString(2, email);
                        pst.setString(3, pwd);
                        }
        ResultSet rs = pst.executeQuery();

                    while(rs.next())
                        {

                        //usertype=rs.getString(1);
                        email=rs.getString(2);
                        //pwd=rs.getString(3);
                        sex=rs.getString(4);

//out.println("<b>");
out.println ("<center><table>");

out.println("<tr>");
out.println("<td>");
                        out.println("<b>Email:</b> "+email);
out.println("</td>");
out.println("</tr>");

out.println("<tr>");
out.println("<td>");
                        out.println("<b>Sex:</b> "+sex);
out.println("</td>");
out.println("</tr>");

}
    catch(Exception e)
    {
        e.printStackTrace();
    }
    //return false;


                  finally
                   {
                   con.close();
                   }
%>
</body>
Idan Adar
  • 44,156
  • 13
  • 50
  • 89

1 Answers1

0

My suggestion:

  1. Read the tutorials provided by IBM to learn about Worklight adapters and how they work
  2. Search Stack Overflow, as this has been asked many times...

What you need to do is adapt the JavaScript snippets provided in the questions below to place the value, instead of inside a table or UL elements, to a textfield or a Select. It is the same principle repeating itself.

Because this is a duplicate, there is no value in copying code to this question as well. Please review the following:

Understand that placing data into HTML elements is unrelated to Worklight, rather it is a standard technique in JavaScript. You need to grasp the concept of that.

  • You can do that by finding the ID of the HTML element and appending data to it, or replacing it completely, or dynamically insert into it. This is demonstrated in the questions above.
Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89