Tomcat-Struts Data Source problem

K

Kris74

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.
 
W

Wendy Smoak

Kris74 said:
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
 
K

Kris74

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
 
W

Wendy Smoak

Kris74 said:
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/[email protected]/

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.
 
K

Kris74

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/[email protected]/

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 (e-mail address removed) for subscribe

thank,

Kris74
 
K

Kris74

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
 
K

Kris74

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top