Hello Ken, You are mixing two things here. One is JDBC and how to use it directly. Another one is JNDI and how to find JDBC data source inside JNDI (in case it's configured there).
Neither of both topics are anyhow related to Tapestry. I would suggest you to look for the answers elswhere, for example here: http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html And about JNDI you can have a look here: http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html for Tomcat http://docs.codehaus.org/display/JETTY/JNDI for Jetty BR Renat 2008/11/12 Ken <[EMAIL PROTECTED]>: > Hi, list. > > I'm using Tapestry 5.0.15. > > I wrote a bit of code: > > String driver = "org.postgresql.Driver"; > String url = "jdbc:postgresql://localhost/sample"; > String username = "hoge"; > String password = "hogo"; > > Properties properties = new Properties(); > properties.put(Context.INITIAL_CONTEXT_FACTORY, driver); > > Context context = new InitialContext(properties); > DataSource ds = (DataSource)context.lookup(url); > Connection con = ds.getConnection(username, password); > > in my service class, and got an exception: > > javax.naming.NoInitialContextException: Cannot instantiate class: > org.postgresql.Driver [Root exception is java.lang.ClassCastException: > org.postgresql.Driver] > > How do I let it work to? > > > On struts & Tomcat, we can use META-INF/context.xml > and just write: > > Context ctx = new InitialContext(); > DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/sample"); > > How do I write on Tapestry? (or Jetty???) > > Thanks. > > Ken. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Best regards, Renat Zubairov --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]