Question

Programming Microsoft Visual Basic 2012/2015 - Create an SQL or Access database with all your friends’...

Programming Microsoft Visual Basic 2012/2015 - Create an SQL or Access database with all your friends’ information and write a program to load the names in the combo box and also search the database and find your friend’s record off the database by name and retrieve all the information from the database to the form including your friend’s picture. You should be able to add new friends, update an existing friends’ information and delete a friend’s record. See the sample below: UNABLE TO ATTACH SAMPLE JPG's

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<%@ page language="java" import="java.util.*;"%>
<%
   List studentList;
   int nouser;
   int i = 1;
   List cityList;
   int nocity;
   int j = 1;
%>
<%
   studentList = (ArrayList) request.getAttribute("studentList");
   nouser = studentList.size();
%>


<html>
<head>
<title>dynamic combobox in servlet</title>
</head>
<body>
   <br>
   <br>
   <center>
       <table border="1" width="300px" bgcolor="bluelight" cellspacing="0"
           cellpadding="0">
           <tr>
               <td width="100%">
                   <form method="GET" action="jsp/studentList">
                       <font color="red"><h3 align="center">Dynamic Combobox
                               List</font>
                       </h3>
                       <table border="1" width="300px" cellspacing="0" cellpadding="0">
                           <tr>
                               <td width="50%"><b>Student Name:</b></td>
                               <td width="50%"><select name="studentId" value="">
                                       <option value="0">---Select Name---</option>
                                       <%
                                           Iterator userit = studentList.iterator();
                                           while (userit.hasNext()) {
                                               while (i <= nouser) {
                                       %>
                                       <option value="<%=i%>"><%=userit.next()%></option>
                                       <%
                                           i++;
                                               }
                                           }
                                       %>
                               </select></td>
                           </tr>
                          
                       </table>

                   </form>
               </td>
           </tr>
       </table>
   </center>
</body>

</html>

package com.napier.test;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class StudentServlet extends HttpServlet {
   public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
       response.setContentType("text/html");
       PrintWriter pw = response.getWriter();
       Connection con = null;
       String url = "jdbc:mysql://10.5.3.121:3306/";
       ;
       String db = "hr";
       String driver = "com.mysql.jdbc.Driver";
       String userName = "hr";
       String password = "hr";
       try {
           Class.forName(driver);
           con = DriverManager.getConnection(url + db, userName, password);
           Statement st = con.createStatement();
           ResultSet rs = st.executeQuery("select * from student");
           List studentList = new ArrayList();
           List clist = new ArrayList();
           while (rs.next()) {
               //request.setAttribute("studentId", rs.getString(2));
               request.setAttribute("studentName", rs.getString(3));
               pw.println("studentId" + " " + "studentName" + "<br>");
               pw.println(rs.getString(2) + " " + rs.getString(3) + "<br>");
               //studentList.add(rs.getString(2));
               studentList.add(rs.getString(3));

           }
           request.setAttribute("studentList", studentList);

       } catch (Exception e) {
           pw.println(e);
       }
       RequestDispatcher dispatcher = getServletContext()
               .getRequestDispatcher("/jsp/Combobox.jsp");
       dispatcher.forward(request, response);
   }

}

Add a comment
Know the answer?
Add Answer to:
Programming Microsoft Visual Basic 2012/2015 - Create an SQL or Access database with all your friends’...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the following SQL statements in Microsoft Access by using the Books database from Week 2...

    Write the following SQL statements in Microsoft Access by using the Books database from Week 2 Assignment 2. Once complete, copy and paste the SQL statements in a Microsoft Word document: Write SQL statements: To update the publisher name from READ WITH US to READ FOR US To verify the updated name field for the publisher with ID 6 To make the following updates to the Publisher table (be careful with WHERE): Make Contact="John Travolta" for publisher with ID number...

  • You will create an Microsoft Access School Management System Database that can be used to store,...

    You will create an Microsoft Access School Management System Database that can be used to store, retrieve update and delete the staff/student. Design an Access database to maintain information about school staff and students satisfying the following properties: 1. The staff should have the following: ID#, name, and classes they are teaching 2. The student should have the following: ID#, name, section, class 3. Create a module containing the section, subject and teacher information 4. Create a module containing student...

  • The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language....

    The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language. The book ISBN number that I am using is: 978-1-285-08416-9 or the UPC code is: 2-901285084168-1. Question 1 Visual Basic 2012 is an object-oriented programming language, which is a language that allows the programmer to use ____________________ to accomplish a program�s goal. Question 2 An application that has a Web user interface and runs on a server is called a(n) ____________________ application. Question 3...

  • I want solution by wampserver 4. Database Programming [8 Marks) a. Create a database in wampserver...

    I want solution by wampserver 4. Database Programming [8 Marks) a. Create a database in wampserver with your National ID. b. Create the table structure with your college ID Number, for the all fields with the proper filed name, data type, size and constraint. c. Modify your php program with necessary mysql database connection. d. When you click register button [in the registration form], save the record into the database and display the result in table format. c. When you...

  • Create the database and tables for the database. Show all SQL statements. Include primary and foreign...

    Create the database and tables for the database. Show all SQL statements. Include primary and foreign keys. Insert data into each table. Show select statements and display the output of each table. Note:Student’s name must be inserted into table as part of the data! Perform the SQL below: Query one table and use WHERE to filter the results. The SELECT clause should have a column list, not an asterisk (*). State the purpose of the query; show the query and...

  • The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind...

    The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. Here is the schema of the database: Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued); Suppliers (SupplierID, CompanyName, ContactName , ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage); Categories (CategoryID, CategoryName, Description, Picture); Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia,  Freight, ShipName,ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry); Order_details (ID, OrderID,...

  • SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and...

    SQL QUERIES 1) Using the Product and PC relations, create both tables in your database and insert all the data. Show the SQL statements to create each table and show a representative SQL insert statement for the data in each table (i.e. you do not need to show insert statements for all the data). – For the remaining questions, assume that your SQL is part of a program function and the function provides the input needed for your SQL query....

  • Rationale The focus of the project is to develop your database programming skills. This project will...

    Rationale The focus of the project is to develop your database programming skills. This project will help you get a fair idea of the sales and distribution system in any organization that has a chain of Carrying and Forwarding Agents (CFAs) or super stockists and stockists. You will be able to implement database programming concepts of ADO.NET in VB.NET and ASP.NET to create a real-life, web-based database application. (VB stands for Visual Basic.) Scenario Smooth Pen, Inc., a pen manufacturing...

  • You are a database consultant with Ace Software, Inc., and have been assigned to develop a...

    You are a database consultant with Ace Software, Inc., and have been assigned to develop a database for the Mom and Pop Johnson video store in town. Mom and Pop have been keeping their records of videos and DVDs purchased from distributors and rented to customers in stacks of invoices and piles of rental forms for years. They have finally decided to automate their record keeping with a relational database. You sit down with Mom and Pop to discuss their...

  • For this course project, you will use various database management and programming techniques to design and...

    For this course project, you will use various database management and programming techniques to design and develop an online sales and distribution system for a fictitious organization. There are two phases—you will complete the first phase this week and the second phase in W5 Assignment 2. Rationale The focus of the project is to develop your database programming skills. This project will help you get a fair idea of the sales and distribution system in any organization that has a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT