This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errors while accessing MySQL database

Robinson Francis
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello and Good day to every one,
I am trying to build a DB based application that will validate login ID of users. This project is part of tutorial that can be found here:

The application will

Ask the user to input his "username" and "password"
Check the existence of this user in the Data Base
If exists, Retrieve his first name and last name from the DB and display them
If not registered, Display "Sorry, you are not registered".

The folder structure of the project can be referred from the Attachement. The Main class that handles connection to the database is the ConnectionManager. java . The code is as below.

The settings for the datasource in my WeblOGic Server is shown in the attached picture.

When I try to run the project and key in the Username and password, I get an error as below.

Your user name is ROBINSON
Your password is FRANCIS
Query: SELECT * FROM users where username='ROBINSON' AND password='FRANCIS'
javax.naming.NameNotFoundException: While trying to look up comp/env/jdbc/important_schema in /app/webapp/LoginExample/4240780.; remaining name 'comp/env/jdbc/important_schema'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(
at weblogic.jndi.internal.ApplicationNamingNode.lookup(
at weblogic.jndi.internal.WLEventContextImpl.lookup(
at weblogic.jndi.internal.WLContextImpl.lookup(
at weblogic.jndi.internal.AbstractURLContext.lookup(
at javax.naming.InitialContext.lookup(
at ExamplePackage.ConnectionManager.getConnection(
at ExamplePackage.UserDAO.login(
at ExamplePackage.LoginServlet.doGet(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at weblogic.servlet.internal.StubSecurityHelper$
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(
at weblogic.servlet.internal.ServletStubImpl.execute(
at weblogic.servlet.internal.ServletStubImpl.execute(
at weblogic.servlet.internal.WebAppServletContext$
at Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(
at weblogic.servlet.internal.WebAppServletContext.execute(
Log In failed: An Exception has occurred! java.lang.NullPointerException

Can you please help me on this? I was told that it has got to do with the way the jdbc datasource is named in the Weblogic console but I am not sure. Please help me on this. Thank you all in advance.
Filename: MySQL Datasource configuration..bmp
Description: DataSource Configuration in Weblogic Console.
File size: 908 Kbytes
[Download MySQL Datasource configuration..bmp] Download Attachment
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic