Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange Problem

 
Vikas
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Klaus Jesper
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..

Klaus
 
Vikas
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works now but my Tomcat doesn't start now
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!