• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JNDI connection

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 42102
933
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sridhar,
You have two typos in there.

DataSorce --> DataSource
e.prinStackTrace --> e.printStackTrace
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic