Note that there are some explanatory texts on larger screens.

plurals
  1. POjavax.naming.NameNotFoundException: Name abcODBC1 is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingConte xt.java:770)
    primarykey
    data
    text
    <p>I'm trying to use Ms Access to test out Connection Pooling but to no avail.And I have read through similar problems at Stackoverflow and elsewhere but still can't resolve the problem.</p> <p>Here's the error code from Tomcat:</p> <pre><code> javax.naming.NameNotFoundException: Name PracticalODBC1 is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:140) at org.apache.naming.NamingContext.lookup(NamingContext.java:781) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:392) at ProcessRegistration.init(ProcessRegistration.java:37) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:619) </code></pre> <p>Here's my context.xml:</p> <pre><code>&lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt; &lt;Context&gt; &lt;!-- Specify a JDBC datasource --&gt; &lt;Resource name="jdbc/odbc:PracticalODBC1" auth="Container" type="javax.sql.DataSource" driverClassName="com.jdbc.odbc.JdbcOdbcDriver" url="jdbc:odbc://localhost:3306/pract1" maxActive="10" maxIdle="4" /&gt; </code></pre> <p></p> <p>And my servlet:</p> <p></p> <p>And my DoPost Servlet:</p> <pre><code>public class ProcessRegistration extends HttpServlet { private DataSource dataSource; private Connection conn; private Statement stmt; DataSource pool; @Override public void init() throws ServletException { try { // Get DataSource Context initContext = new InitialContext(); pool = (DataSource) initContext.lookup("java:/comp/env/PracticalODBC1"); if (pool == null) { throw new ServletException("Unknown DataSource 'jdbc/PracticalODBC1'"); } } catch (NamingException e) { e.printStackTrace(); } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); conn = null; ResultSet rs = null; PreparedStatement ps = null; stmt = null; try { conn = pool.getConnection(); stmt = conn.createStatement(); // inserting records into database ----- } catch (SQLException ex) { Logger.getLogger(ProcessRegistration.class.getName()).log(Level.SEVERE, null,ex); } finally { try { if (rs != null) { rs.close(); rs = null; } if (stmt != null) { stmt.close(); stmt = null; } if (conn != null) { conn.close(); conn = null; } } catch (SQLException e) { throw new ServletException("Servlet records", e); } } out.close(); </code></pre> <p>MySQL Connector jar is already placed in the lib.</p> <p>Hope someone can kindly advise me what went wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload