Results 1 to 1 of 1
  1. #1
    Mateen is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Lightbulb how to access derby database with servlets

    i have created simple derby database and i m using glassfish server on netbeans 6.1 and i m not getting how to access it using servlets through which object

    i tried with the following piece of code

    import java.io.*;
    import java.sql.*;
    import javax.activation.DataSource;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class serv1 extends httpservlet(...)
    {
    .....
    out.println("<body>");
    context ct = new Initialcontext();
    datasource ds = (datasource) ct.lookup();
    // how to access a database using this lookup method
    connection con = ds.getconnection(); // displaying error
    statement st = con.createstatement();
    .....
    }

    so there are two problems here
    1: how to lookup
    2: how to get connection

    so is there any body here can solve my problem
    Last edited by Mateen; 09-07-2011 at 01:39 PM.

Similar Threads

  1. Using Derby Database in Netbeans
    By DavidG24 in forum New To Java
    Replies: 1
    Last Post: 09-14-2009, 02:29 PM
  2. Replies: 2
    Last Post: 02-11-2009, 05:43 AM
  3. saving date and time in a derby database from an ejb module
    By Dave in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-22-2008, 12:14 PM
  4. File Access Through Servlets
    By bipinkrishna15 in forum Java Servlet
    Replies: 1
    Last Post: 05-27-2008, 11:58 AM
  5. Replies: 1
    Last Post: 08-07-2007, 08:51 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
  •