Tomcat-Struts Data Source problem

Discussion in 'Java' started by Kris74, Jul 18, 2005.

  1. Kris74

    Kris74 Guest

    hello! I develop a Struts application and I have a problem with
    starting my Tomcat. I sought why and I know that the problem is of Data
    Source. But I did not find a solution.

    Here my declaration of Data Source in Sruts-config.xml :

    <data-sources> <data-source
    type="org.apache.commons.dbcp.BasicDataSource"> <set-property
    property="driverClassName" value="com.mysql.jdbc.Driver" />
    <set-property property="url" value="jdbc:mysql://localhost/bddStruts"
    /> <set-property property="username" value="root" /> <set-property
    property="password" value="struts" /> <set-property
    property="maxActive" value="12" /> <set-property property="maxWait"
    value="5000" /> <set-property property="defaultAutoCommit" value="true"
    /> <set-property property="defaultReadOnly" value="false" />
    <set-property property="validationQuery" value="SELECT COUNT(*) FROM
    users" /> </data-source> </data-sources>

    I use NetBeans, and I have this error in the console:

    GRAVE: Initializing application data source
    org.apache.struts.action.DATA_SOURCE

    org.apache.commons.dbcp.SQLNestedException: Cannot create
    PoolableConnectionFactory (Communication link failure:
    java.io.IOException, underlying cause: Unexpected end of input stream

    If somebody could help me it would be very nice.

    I have been blocked for one week.

    I cannot any more what make.

    Thank you for your help.

    Ps: Sorry for the expression, I am French.
     
    Kris74, Jul 18, 2005
    #1
    1. Advertising

  2. Kris74

    Wendy Smoak Guest

    "Kris74" <> wrote in message:

    > hello! I develop a Struts application and I have a problem with
    > starting my Tomcat. I sought why and I know that the problem is of Data
    > Source. But I did not find a solution.
    >
    > Here my declaration of Data Source in Sruts-config.xml :
    >
    > <data-sources>


    I'm not entirely sure if that _should_ work, but you're encouraged to
    configure the data sources in your container rather than within Struts.

    For Tomcat 5.5:
    http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html

    If you need more help, please come join us on the Struts User mailing list:
    http://struts.apache.org/mail.html

    --
    Wendy Smoak
     
    Wendy Smoak, Jul 18, 2005
    #2
    1. Advertising

  3. Kris74

    Kris74 Guest

    Thank you for your answer, but I already read the Website that you
    propose for Tomcat 5.

    I don't undertand how ask my questions on struts.apache.org

    Thank

    Kris74
     
    Kris74, Jul 18, 2005
    #3
  4. Kris74

    Wendy Smoak Guest

    "Kris74" <> wrote

    >
    > I don't undertand how ask my questions on struts.apache.org
    >


    First search the archives of struts-user to see if your question has already
    been answered:
    http://www.mail-archive.com//

    If you still need to post a question to the list, visit
    http://struts.apache.org/mail.html and click on the 'Subscribe' link under
    STRUTS-USER Mailing List. There are other options, including news.gmane.org
    which may be more attractive since you're (obviously) familiar with Usenet.

    Sorry, I'm just not familiar enough with DataSource to be able to help, but
    there are plenty of people on the list who can.

    --
    Wendy Smoak
     
    Wendy Smoak, Jul 18, 2005
    #4
  5. Kris74

    Kris74 Guest

    Wendy Smoak a écrit :

    > First search the archives of struts-user to see if your question has already
    > been answered:
    > http://www.mail-archive.com//


    ok thank you for the web page, but some people have the same problem
    but they do not have the solutions.

    > If you still need to post a question to the list, visit
    > http://struts.apache.org/mail.html and click on the 'Subscribe' link under
    > STRUTS-USER Mailing List.


    I send an e-mail at for subscribe

    thank,

    Kris74
     
    Kris74, Jul 20, 2005
    #5
  6. Kris74

    Kris74 Guest

    I can connect to my database with a simple classe Java like this :
    package javappli;

    import java.sql.*;

    public class Main {

    public static void main(String[] args){

    String pilote = "com.mysql.jdbc.Driver";

    try{
    Class.forName(pilote);
    Connection connexion =
    DriverManager.getConnection("jdbc:mysql://localhost/articles","root","root");
    connexion.setAutoCommit( true );
    Statement instruction = connexion.createStatement();
    ResultSet resultat = instruction.executeQuery("SELECT *
    FROM articles");
    while(resultat.next()){

    System.out.println("code:
    "+resultat.getString("code"));
    System.out.println("nom:
    "+resultat.getString("nom"));
    System.out.println("Prix:
    "+resultat.getFloat("prix"));
    System.out.println("Stock actuel:
    "+resultat.getInt("stockActuel"));
    System.out.println("Stock minimum:
    "+resultat.getInt("stockMinimum"));

    }
    }
    catch (Exception e){

    System.out.println("driver failed : "+e);
    }
    }
    }
    In Another test, I create a datasource with Tomcat Admin in
    Ressources->datasources like this:
    JNDI Name: jdbc/test
    Data Source URL:jdbc: mysql://localhost:3306/test?autoReconnect=true
    JDBC Driver Class: com.mysql.jdbc.Driver
    User Name: root
    Password: root
    Max. Active Connections: 4
    Max. Idle Connections: 2
    Max. Wait for Connection:5000

    And modify a context.xml like this:

    <Context path="/test">
    <ResourceLink name="jdbc/test"
    type="javax.sql.DataSource"
    global="jdbc/test"/>
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="test" suffix=".log" timestamp="true"/>

    And the web.xml like this :

    <resource-ref>
    <description>Connection pool</description>
    <res-ref-name>jdbc/test</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

    But I doesn't work, if I try to execute an application with a simple
    JSP.

    If you have ideas, give me them
    Thank

    Kris
     
    Kris74, Jul 29, 2005
    #6
  7. Kris74

    Kris74 Guest

    I forgot to give my error message :

    javax.servlet.ServletException: Unable to get connection, DataSource
    invalid: "org.apache.commons.dbcp.SQLNestedException: Cannot create
    JDBC driver of class ''

    thank,

    Kris74
     
    Kris74, Jul 29, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aleksandar Matijaca
    Replies:
    2
    Views:
    8,325
    Aleksandar Matijaca
    Sep 19, 2004
  2. yzzzzz
    Replies:
    0
    Views:
    852
    yzzzzz
    Jan 7, 2005
  3. Stewart
    Replies:
    3
    Views:
    3,482
    Stewart
    Aug 18, 2005
  4. Merlijn
    Replies:
    0
    Views:
    3,463
    Merlijn
    Mar 24, 2006
  5. Author Tarun Tyagi
    Replies:
    0
    Views:
    718
    Author Tarun Tyagi
    Dec 29, 2004
Loading...

Share This Page