Subject cannot send data to firebirdsql via servlet or jsp
Author Vertus Hector
Hello, I,m Hector
Please Help me to realise this project. I,ve installed the firebirdsql super server 1.03 on linux redhat 8.0. i,m using jakarta-tomcat-5.0.2 like servlet container or web server . The installation of firebird is located at "/opt/interbase", firebird is working properly and starts at boot when linux starts, and i ,ve placed the jca-jdbc driver at "/usr/share/java/jbird" the jar files are on the  CLASSPATH (/etc/profile),i ve download it at www.ibphoenix.com and so the jca-jdbc driver. See below my html page , servlet and Database procedures. Or, explain me how to use jdbc driver for firebirdsql on linux redhat because this is my prefered Database.

There is my html page
 

<html>

   <head>

      <title>Nouveau Salari�</title>

   </head>

 

   <body bgcolor="#FFFFFF" text="#000000" link="#0066CC" vlink="#006666" alink="#996699">

 

       <form name="FrmEmp" action="/PadasaWeb/servlet/ListeEmp" method="Post">

 

        <BR>

        <BR>

 

         <table  border="1" Align="Center">

        <tr>

        <td>

 

         <table  border="0" Align="Center">

           <tr>

             <td>Code</td>

             <td><input type="text" name="code" value=""></td>

           </tr>

           <tr>

             <td>Nom</td>

             <td><input type="text" name="nom" value=""></td>

           </tr>

           <tr>

             <td>Prenom</td>

             <td><input type="text" name="prenom" value=""></td>

           </tr>

           <tr>

           <td>Sexe</td>

           <td>

                <select name="sexe">

                  <option value="Feminin"> Feminin</option>

                          <option value="Masculin"> Masculin</option>

                </select>

                </td>

            <tr>

 

         </table>

 

         <td>

         <tr>

         </table>

 

        <BR>

            <BR>

 

            <table border="0" align="center">

          <td colspan="2" align="center"><input type="submit" name="BtnSave" value="Appliquer">

          <input type="reset" name="reset" value="Reinitialiser"></td>

                    </td>

            </table>

 

        <BR>

            <BR>

 

       </form>   

 

   </body>

 

</html>

 
 
There is my Servlet (ListeEmp.java)

import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
import java.util.*;


public class ListeEmp extends javax.servlet.http.HttpServlet
{

   private final String content = "text/html";
   private Connection con;
   private Statement stmt;
   private ResultSet rs;
   private String user = "SYSDBA";
   private String password = "masterkey";

   private String url="jdbc:firebirdsql://Padasa-Server:3050/home/Utilitaires/DBtest.gdb";


public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
{
  doPost(request, response);
}

public void doPost(
   javax.servlet.http.HttpServletRequest request,
   javax.servlet.http.HttpServletResponse response)
   throws javax.servlet.ServletException, java.io.IOException
{
   response.setContentType(content);
   PrintWriter out = response.getWriter();

   String code = request.getParameter("code");
   String nom = request.getParameter("nom");
   String prenom = request.getParameter("prenom");
   String sexe = request.getParameter("sexe");

   if (code.equals("")
       || nom.equals("")
       || prenom.equals("")
       || sexe.equals(""))
   {
      RequestDispatcher rd =
      getServletContext().getRequestDispatcher("/AddEmp.htm");
      rd.include(request, response);
   }
   else
   {


       try
       {
           getConnection();

           String insertRow1 =
               "INSERT INTO TblEmp"
                   + "values("
                   + code
                   + ",'"
                   + nom
                   + "','"
                   + prenom
                   + "','"
                   + sexe
                   + "')";
           stmt = con.createStatement();
           stmt.executeUpdate(insertRow1);

           String query = "select * from TblEmp";
           rs = stmt.executeQuery(query);
           out.println(
               "<h1><b> Voici les informations que vous aviez saisit </b></h1>");

           while (rs.next())
           {

               out.println("<html>");
               out.println("<body>");
               out.println("<head>");
               out.println("<title> Saisie!</title>");
               out.println("</head>");
               out.println("<body>");
               out.println("<hr>");
               out.println("<h1> Code:   " + rs.getString("code") + "</h1>");
               out.println("<h1> Nom:   " + rs.getString("nom") + "</h1>");
               out.println("<h1> Prenom:   " + rs.getString("prenom") + "</h1>");
               out.println("<h1> Sexe:  " + rs.getString("sexe") + "</h1>");
               out.println("<hr>");
               out.println("</body>");
               out.println("</html>");
     } // Fin while

       }
       catch (Exception e)
       {
           System.out.println(e);
       }
       try
       {
           if (stmt != null)
           {
               stmt.close();
           }
           if (rs != null)
           {
               rs.close();
           }
           if (con != null)
           {
               con.close();
           }
       }
       catch (Exception e)
       {
           e.printStackTrace();
       }

   }
}

 
public Connection getConnection() throws SQLException, IOException
{
   //Chargement du Pilote (Loading the Driver)
   try
   {
     Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
   }
   catch (Exception e)
   {
       System.out.print("Incapable de trouver le pilote de FirebirdSQL ");
       e.printStackTrace();
   }

   //Etablir la connection
   try
   {
       con = DriverManager.getConnection(url,user,password);

       stmt = con.createStatement();
   }
   catch (SQLException ex)
   {
       System.err.println("SQLException: " + ex.getMessage());
   }

   return (this.con);
}


} //Fin de la classe


Database

cd /opt/interbase/bin
./isql start
create database �/home/Utilitaires/DBtest.gdb� user �SYSDBA� password �masterkey�;
commit;

Create table TblEmp(code varchar(10),nom varchar(50),prenom varchar(75),sexe varchar(10));
commit;
quit;

---------------------------------------------------------
Please help me to send Data on TblEmp via servlet or jsp using JDBC with firebird.

 


Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!