Start New Discussion within our Software Development Community

hi everyone, i am new to netbeans. i am creating a system that can allocate rooms to students. My main problem is how to find out which rooms are full and which ones are available.
I am using Mysql and Java Netbeans. I have read some of the tutorials but i haven't fond out how i can do it.
does anyone know how i can do this in netbeans. Please help

i cant give you the code but i can tell you how to retrive data from database.
you can take help from the following example.

1.the user enter the table name on the web page the coding is given below

  <body bgcolor="green">
  <form  name="f1" action="http://localhost:8084/Database/TestJdbc" method="Post">
      Enter the table name : <input type="text" name="t1"  /><br>
       <input type="submit" value="OK" />

2.the server side coding is given below

 * Created on August 30, 2009, 8:26 PM

import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

 * @author G@Me BuDDiE
 * @version
public class TestJdbc extends HttpServlet {
    /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        /* TODO output your page here*/
        out.println("<title>Servlet TestJdbc</title>");
        out.println("<h1>Servlet TestJdbc at " + request.getContextPath () + "</h1>");
             Connection conn;
             Statement stmt;
             String s = request.getParameter("t1");
             ResultSet rs=stmt.executeQuery("select * from  " +s);
             out.println("<table border = 1>");
         }catch(Exception e){}
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    /** Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
        return "Short description";
    // </editor-fold>

you have to create a database and store the database where your java file is stored which will be easier during coding.any more help you can ask.

By giving out solution you are not helping to the learning process, you just helping lazy students to pass their assignments and fail in real life

That is not a good example and it is a bad way to do things. Not to mention that the OP said nothing about html code.

Only the database connectivity is almost ok. You forgot to close the ResultSet, Statement and ResultSet.
First: How do you know that the table entered at the field will always have 2 columns.
Second: Never put html code in servlets. Read the data from the DB, put those into an array of objects using OOP, and then send the array of objects back to a jsp through the request in order to be displayed at the jsp page.

Of course the above would have been helpful if the OP has said that the whole application would be web application.


Of course, first you have to create the database and store it in the your Java file. You can develop MySQL backed applications with Netbaens and JAVA which might could give you the other Web services. It would be easier for you if you create the proper database so that you can allocate rooms to the students.

                I want a code in which a jsp login page is calling a servlet and the server is connected to the again new jsp in which it shows the welcome page or it says that you are a valid user or it may be invalid user....plz ans as soon as possible, 
This article has been dead for over six months. Start a new discussion instead.