Subject | Re: [Firebird-Java] Cannot send data to firebirdsql via jdbc or jaybird |
---|---|
Author | Rick Fincher |
Post date | 2003-07-01T19:57:07Z |
Hi,
When you say you have unzipped the JayBird jar files in
CATALINA_HOME/common/lib do you mean you put firebirdsql-full.jar (or
firebirdsql.jar and mini-j2ee.jar and mini-concurrent.jar) in there or that
you unzipped them too?
It (or they) should be in jar format in CATALINA_HOME/common/lib.
You also need to be sure Padasa-Server can be resolved. You may need to put
it in as Padasa-Server.mycompany.com or whatever your fully specified name
is. You can also use localhost if the Firebird server is on the same machine
as Tomcat and the name "localhost" resolves.
You may want to try writing a simple Jave command line program to verify
that Firebird and JayBird are installed and working properly.
After that you can move on to a servlet and know that the connection should
work.
Also, you should really think about using JayBird to create a DataSource in
Tomcat, rather than loading the driver in your servlet. It is much more
flexible and it makes Tomcat responsible for loading the driver. That way
you get logging information in Tomcat if there is a problem.
Did you get any error messages in the Tomcat logs?
It is a bad idea to use SYSDBA and masterkey for username and password. I'm
sure you know this, but people often forget to GRANT access to whatever
non-SYSDBA user they end up using and that causes an error.
Rick
When you say you have unzipped the JayBird jar files in
CATALINA_HOME/common/lib do you mean you put firebirdsql-full.jar (or
firebirdsql.jar and mini-j2ee.jar and mini-concurrent.jar) in there or that
you unzipped them too?
It (or they) should be in jar format in CATALINA_HOME/common/lib.
You also need to be sure Padasa-Server can be resolved. You may need to put
it in as Padasa-Server.mycompany.com or whatever your fully specified name
is. You can also use localhost if the Firebird server is on the same machine
as Tomcat and the name "localhost" resolves.
You may want to try writing a simple Jave command line program to verify
that Firebird and JayBird are installed and working properly.
After that you can move on to a servlet and know that the connection should
work.
Also, you should really think about using JayBird to create a DataSource in
Tomcat, rather than loading the driver in your servlet. It is much more
flexible and it makes Tomcat responsible for loading the driver. That way
you get logging information in Tomcat if there is a problem.
Did you get any error messages in the Tomcat logs?
It is a bad idea to use SYSDBA and masterkey for username and password. I'm
sure you know this, but people often forget to GRANT access to whatever
non-SYSDBA user they end up using and that causes an error.
Rick
----- Original Message -----
> Hi
> Please Help me to realise this project.
> I,ve installed the firebirdsql super server 1.03 for linux i,m using
> Linux RedHat 8.0 and 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 unziped the jaybird jar files
> at "CATALINA_HOME/common/lib", I put the jar files in the CLASSPATH
> (/etc/profile), I,ve downloaded firebird at www.ibphoenix.com and
> so the class 4 jca-jdbc driver. See below my html page , servlet and
> Database procedures. When i click on the submit button there is no
> message error and the next page is blank
>
> Please explain me how to use jdbc driver, and
> then to send data in Database via Servlet or JSP on firebirdsql for
> linux 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 my servlet or jsp using
> JDBC (jaybird)