Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

Tomcat-Struts Data Source problem

Thread view: 
Kris74 - 18 Jul 2005 08:27 GMT
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.
Wendy Smoak - 18 Jul 2005 14:41 GMT
"Kris74" <lkristofer@caramail.com> 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
[quoted text clipped - 3 lines]
>
> <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

Signature

Wendy Smoak

Kris74 - 18 Jul 2005 15:17 GMT
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
Wendy Smoak - 18 Jul 2005 18:08 GMT
> 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/user%40struts.apache.org/

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.

Signature

Wendy Smoak

Kris74 - 20 Jul 2005 15:29 GMT
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/user%40struts.apache.org/

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 user-subscribe@struts.apache.org for subscribe

thank,

Kris74
Kris74 - 29 Jul 2005 09:45 GMT
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 - 29 Jul 2005 13:37 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.