jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Strange Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Strange Problem" Watch "Strange Problem" New topic

Strange Problem

Ranch Hand

Joined: Dec 16, 2004
Posts: 63
Hello All,

I am writing a sample Strut to connect to the database but when I am compiling my DAO class it throws me following strange error:-

D:\tomcat\jakarta-tomcat-5.0.27\common\lib\servlet-api.jar(javax/sql/DataSource.java):35: class DataSource is public, should be declared in a file named DataSource.java
(source unavailable)
1 error

Following is the piece of code that I have used in my DAO class:-

import javax.sql.DataSource;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MasterDAL {
public static void addName(NameVO name, DataSource dataSource)
throws Exception {

Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

try {

conn = dataSource.getConnection();
stmt = conn.createStatement();

Following is what I have configured in my strut-config.xml

<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:3306/test" />
<set-property property="username"
<set-property property="password"
value=" "/>

What mistake I have made??? Kindly help.

Thank you and Regards
[ January 29, 2005: Message edited by: Vikas Sharda ]
Klaus Jesper

Joined: Jan 20, 2005
Posts: 15
Try to move your jar-file with the mysql-jdbc-driver to a different directory, so that the path to the jar has no spaces. Let me know if it works now..

Ranch Hand

Joined: Dec 16, 2004
Posts: 63
It works now but my Tomcat doesn't start now
I agree. Here's the link: http://aspose.com/file-tools
subject: Strange Problem
It's not a secret anymore!