• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange Problem

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works now but my Tomcat doesn't start now
 
Those are the largest trousers in the world! Especially when next to this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic