Results 1 to 2 of 2
  1. #1
    berlindutza is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default Problems about connection to a database

    Hi!
    I've imported a dynamic projects which connects to an old Cloudscape v5.1 database. It works fine, that means the different .jsp pages connect to the database and can work with it.
    Now, I want to set up a new dynamic web project and work with the same database. I'm trying to set up a connection (through a datasource), but I always get an error!

    Here's the code:
    javax.naming.InitialContext ctx = new javax.naming.InitialContext();
    ds = (javax.sql.DataSource)ctx.lookup("java:comp/env/" + datasourceRef);
    con = ds.getConnection();

    and the error I get:
    Connection exception: Name "comp/env/ClipsAndTacks" not found in context "java:".
    Exception thrown: null
    java.lang.NullPointerException

    I have to admit, that I don't understand anything from the first two rows of the code.
    Can someone help/explain me?
    I would really appreciate every answer!
    Thanks a lot!

  2. #2
    FON
    FON is offline Senior Member
    Join Date
    Dec 2009
    Location
    Belgrade, Serbia
    Posts
    366
    Rep Power
    6

    Default

    You have to learn some basic JNDI
    and find a way to configure your environment.

    Here is how it is done with Tomcat :

    The Tomcat 4 Servlet/JSP Container - JNDI Resources HOW-TO

    i hope it will help

    cheers!

Similar Threads

  1. connection to database
    By buston01 in forum JDBC
    Replies: 4
    Last Post: 02-21-2010, 02:32 AM
  2. getting database connection
    By ravidasineni in forum AWT / Swing
    Replies: 1
    Last Post: 11-22-2009, 03:01 AM
  3. database connection in jsf
    By Srikala in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-06-2008, 07:53 AM
  4. Database Connection
    By CompleteBeginner in forum New To Java
    Replies: 2
    Last Post: 05-24-2008, 03:30 PM
  5. Database Connection
    By vipinkumarsolanki in forum Advanced Java
    Replies: 2
    Last Post: 11-26-2007, 07:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •