3 Replies Latest reply on Apr 30, 2015 7:16 AM by wdfink

    sun.jdbc.odbc.JdbcOdbcDriver from [Module "deployment.XXX.war:main" from Service Module Loader]

    aoitora

      Hello,

      I'm currently trying to code in Eclipse a simple application (using jsp) where we have an internet page showing a catalog of books from a database. The problem is, I get this error sun.jdbc.odbc.JdbcOdbcDriver from [Module "deployment.myfirstProject.war:main" from Service Module Loader] and nothing else (see image attached)ModuleLoader.png [the MyFirstServlet.java and web.xml are not related to this project].

      With such an unexplicit error, it is quite difficult to solve that problem which might be, according to many links on Google, related to JBoss.

      Here is my code (whose syntax is not coloured in the preview, I hope it will be once the post is sent)

      MyApp.jsp

       

       

      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1" import="java.sql.*,java.io.*"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <link rel="stylesheet" type="text/css" href="MyAppStyle.css">
      <title>Gestion de stocks de livres</title>
      </head>
      <body>
      <!-- Il faudra récupérer les livres depuis une base de données. Pour le moment, ils sont affichés directement.-->
      <!-- Il faudra également indiquer "Epuisé" si qté==0 -->



      <%
      Connection conn = null;
        try {
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         conn = DriverManager.getConnection("jdbc:odbc:MYDATABASE","XXXX","XXXX");
         Statement statement = conn.createStatement();
         ResultSet rs = statement.executeQuery("SELECT isbn, Titre_livre, auteur, quantite FROM Livres");%>

      <table id="tableauDeLivres">
        <tr><th>Titre</th>
         <th>Auteur</th>
         <th>ISBN</th>
         <th>Quantité restante</th>
        
        </tr>
        <%
        while (rs.next()){
         System.out.println("test");
         out.println("<tr>\n<td>"+ rs.getString("isbn")+"</td>");
         out.println("<tr>\n<td>"+ rs.getString("titre_livre")+"</td>");
         out.println("<tr>\n<td>"+ rs.getString("auteur")+"</td>");
         out.println("<tr>\n<td>"+ rs.getString("quantite")+"</td>\n</tr>");
        }
        rs.close();
        } catch (IOException ioe){
         out.println(ioe.getMessage());
        } catch (SQLException sqle){
         out.println(sqle.getMessage());
        } catch (ClassNotFoundException cnfe){
         out.println(cnfe.getMessage());
        } catch (Exception e){
         out.println(e.getMessage());
        }
        finally{
         try {
          if (conn != null){
           conn.close();
          }
         }
         catch (SQLException sqle){
          out.println(sqle.getMessage());
         }
        }
        %>
        </table>
      <!-- <div id="boutons">
      <input type="button" value="Ajouter un livre"> <input type="button" value="Supprimer la sélection"><input type="submit" value="Ajouter au panier"><br/>
      <input type="button" value="Tout Cocher"><input type="button" value="Tout Décocher">
      </div> -->
      </body>

       

       

      Any help is welcome!

       

      EDIT : it appears that this error happens with another code I wrote, following a JSP book down to the last semi-column. I can connect to my base with a java class (to add data) but when it comes to the JSP file (to JBoss?) I've got this error.

        • 1. Re: sun.jdbc.odbc.JdbcOdbcDriver from [Module "deployment.XXX.war:main" from Service Module Loader]
          wdfink

          Difficult to say somthing with that information ...

           

          What did you mean with "I can connection to my base with a java class" ? A different standlone java class?

          It looks to me that you miss the driver class in your deployment, did you pack the into the application?

          Which JBoss version do you use? There are different options to install the driver for different versions.

          • 2. Re: sun.jdbc.odbc.JdbcOdbcDriver from [Module "deployment.XXX.war:main" from Service Module Loader]
            aoitora

            Well I have a class (called InsertNewBooks.java) where I can add some books in my db. Here is a tiny bit of that code

            
             {Class.forName
            "sun.jdbc.odbc.JdbcOdbcDriver");
            
            conn = DriverManager.getConnection("jdbc:odbc:XXX","XXX","XXX");
            
            stmt = conn.prepareStatement("INSERT INTO Livres VALUES (?,?,?,?)");
            stmt.setString(1, "0439023483");
            stmt.setString(2,"Hunger Games");
            stmt.setString(3, "S.Collins");
            
            stmt.setString(4, "4");
            
            stmt.executeUpdate();
            
            
            

            (once again the preview is terrible and I'm sure I just suppressed things but I can't see a thing, I hope it will look better in the message...)

             

            There is no problem here, that code really inserts my values into my database when I run it.

             

            I'm using JBoss AS 7.1

             

            Anyway, my boss is back from his holidays and he told me another way to connect (where we are not using ODBC)  so I guess I'm just going to stick to what he's telling me (since that's the goal of this training). But I will try to correct this code anyway so I'm still listening to any suggestion =D

            • 3. Re: sun.jdbc.odbc.JdbcOdbcDriver from [Module "deployment.XXX.war:main" from Service Module Loader]
              wdfink

              Is that class also inside of JBoss?

              In any case I would recommend to use the datasource configuration and use JNDI or injection to retrieve a DB connection from the pool.