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