Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Access-Servlet JDBC-ODBC

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
yesterday i have posted Question Regarding how to Connect Access with Servlet running in Weblogic Server?.i have got solution now.so here is what i have made step-by-step:

1. create DSN through Control Panel.
2. In weblogic Console i have Set various Properties for DataBase Service Node Like :
  • ConnectionPool

  • 1.Name - JDBCAccessPool
    2.URL - jdbcdbc:Db
    3.Driver Classname - sun.jdbc.odbc.JdbcOdbcDriver
    4.Poperties : -user=node
    password=none
    server=none
  • Data Sources

  • 1.Name - MyJDBC Data Source[/list]
    2.JNDI Name - MyDataBase
    3.Pool Name - JDBCAccessPool
    -------------------------------------------------
    Servlet code is as follow :
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.naming.*;
    public class HelloWordServlet extends HttpServlet {
    public void doGet(HttpServletRequest req,
    HttpServletResponse res) throws IOException{
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    String name=req.getParameter("name");
    out.println("<html><head><title>Hello World!");
    out.println("</title></head>");
    out.println(name);
    Context ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,
    "t3://jariwalabd:7001");
    try {
    ctx = new InitialContext(ht);
    javax.sql.DataSource ds
    = (javax.sql.DataSource) ctx.lookup ("MyDataBase");
    java.sql.Connection conn = ds.getConnection();
    // You can now use the conn object to create
    // Statements and retrieve result sets:
    Statement stmt = conn.createStatement();
    stmt.execute("select * from Directory");
    ResultSet rs = stmt.getResultSet();
    while (rs.next()) {
    String s = rs.getString("NAME");
    out.println(s);
    }
    // Close the statement and connection objects when you are finished:
    stmt.close();
    conn.close();
    }
    catch (NamingException e) {
    // a failure occurred
    }
    catch (Exception e) {
    out.println(e);
    }
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    }
    }
    out.println("<body><h1>Hello !</h1></body></html>");
    }
    }

    -----------------------------------------------
    [ July 30, 2002: Message edited by: Marilyn de Queiroz ]
     
    Ranch Hand
    Posts: 278
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanx for sharing with us.
    Good Luck
    Rashid
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic