aspose file tools*
The moose likes Struts and the fly likes JNDI connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JNDI connection" Watch "JNDI connection" New topic
Author

JNDI connection

veesam sridhar
Ranch Hand

Joined: Oct 18, 2005
Posts: 51
Hi,

I configured JNDI connection and I am able access the datasource from jsp

I wrote a normal class for getting connection in src directoy of my application:
-----------------

import javax.naming.*;
import javax.sql.*;
import java.sql.*;


public class Connection{

public static Connection getConnection()
{
try {
Context ctx=new InitialContext() ;
if (ctx==null)
throw new Exception("No Context is there");
DataSorce ds=(DataSorce) ctx.lookup("java:comp/env/jdbc/mysqldb");
if(ds!=null)
{
Connection conn=ds.getConnection();
return conn;
}
else
throw new Exception("Could not get connection");
} catch(Exception e) {
e.prinStackTrace();
}

}




}


-----------------

I am trying to compile that class.

But it is govoing the following error:
---------------------------------------------------------
Connection.java:4: cannot find symbol
symbol : class DataSorce
location: package javax.sql
import javax.sql.DataSorce;
^
Connection.java:17: cannot find symbol
symbol : class DataSorce
location: class Connection
DataSorce ds=(DataSorce) ctx.lookup("java:comp/env/jdbc/mysqldb");
^
Connection.java:17: cannot find symbol
symbol : class DataSorce
location: class Connection
DataSorce ds=(DataSorce) ctx.lookup("java:comp/env/jdbc/mysqldb");
^
Connection.java:26: cannot find symbol
symbol : method prinStackTrace()
location: class java.lang.Exception
e.prinStackTrace();
^
4 errors

--------------------------------------------------



I am not able to find out why it is saying Cann ot find DataSource symbol.

Please help me.


Thank you,
Sridhar.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

Sridhar,
You have two typos in there.

DataSorce --> DataSource
e.prinStackTrace --> e.printStackTrace


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI connection