posted 19 years ago
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-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:3306/test" />
<set-property property="username"
value="root"/>
<set-property property="password"
value=" "/>
</data-source>
</data-sources>
What mistake I have made??? Kindly help.
Thank you and Regards
Vikas
[ January 29, 2005: Message edited by: Vikas Sharda ]